Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
In my table images are in binary format,want to retrieve images using wcf services and linq to sql concepts. and want to bind the images in multiple locations of webpage. how to get the images can anyone help me...
Posted 7-Mar-12 0:33am
Comments
Navin Kumar.K.Subramanian at 7-Mar-12 5:37am
   
Have you configured the WCF service and got the data from the table.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

1. Create Service Method with return type as byte[]. This method ll return the image byte array from the DB-Table based on your conditions.
2. In page, Create byte[] variable to get output above service.
3. Follow the below steps
Int32 offset =78;
byte[] imagews=wservice.getimage();
Int32 offset =78;
System.IO.MemoryStream ms = new System.IO.MemoryStream ();
ms.Write(imagews, offset, imagews.Length - offset);
System.Drawing.Bitmap imgJpg= new System.Drawing.Bitmap(ms);
imgJpg.Save(Server.MapPath ("FromDB.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg );
ms.Close();
ImageFromDB.ImageUrl = Server.MapPath("FromDB.jpg"); // this image can be used across the pages.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

1. Getting data from database is not really WCF. It is job of ADO.Net. You can get the images from database using basic ADO.Net code. Lot of example can be found on MSDN and web in general to do this.
2. Once you have retrieved the image, I would suggest you send that to the client via service in binary format since that will be quicker. You can also take a look at "compressing images in .Net" if you are dealing with big pictures.
3. Check this[^] article. HTH.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 BillWoodruff 260
1 Afzaal Ahmad Zeeshan 252
2 OriginalGriff 251
3 Mathew Soji 234
4 Maciej Los 230
0 OriginalGriff 6,419
1 Sergey Alexandrovich Kryukov 6,008
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 4,070


Advertise | Privacy | Mobile
Web01 | 2.8.1411019.1 | Last Updated 9 Mar 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100