Sai Yang

Sai Yang

  • NA
  • 136
  • 27.4k

[C#] how to view image ????

May 2 2018 10:17 AM
I have already convert a picture box to byte then insert into database as image datatype.
 
The proble:
 
 I need to preview it on to the picturebox again when datagrid cellclick event.
 
and I am using the following code:
 
string stimg = "select images from tb_employee where Boolean='True' and id='" + classinfo.eid + "'";
DataTable dtimg = ClassConnection.getdata(stimg, "tbname");
if (dtimg.Rows.Count == 1)
{
try
{
MemoryStream ms;
byte[] bviewimg = (byte[])dtimg.Rows[0]["images"];
ms = new MemoryStream(bviewimg);
ms.Seek(0, SeekOrigin.Begin);
picem.Image = Image.FromStream(ms);
}
catch
{
picem.Image = null;
}
}
 
this doesn't work for me .
 
What I can do next??
 
Any body has idea to solve this problem, please share it to me?>
thank you in advance. 

Answers (16)