Displaying image in pictureBox direct from database


You can display image directly from database into picture box.



//Declaring byte array
Byte[] bImage = new Byte[0];

//Casting photo data and holding in byte type variable
//dr is DataRow and "CPhoto" is name of column.
bImage = (Byte[])(dr["CPhoto"]);

//Creating object of MemoryStream
System.IO.MemoryStream msData = new System.IO.MemoryStream(bImage);

//Displaying image in picturebox from memorystream object
pboClient.Image = System.Drawing.Image.FromStream(msData);


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: