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.
Maen BadwanPosted Aug 30, 2018, 6:53 AM
https://www.codeproject.com/Articles/33310/C-Save-and-Load-Image-from-Database
If you already tried this approach and it doesn’t work, then the issue it is most likely related to the format or compression of the image you save-load from the database.
For example, if the image format is not natively supported by Microsoft .NET classes (such as uncompressed TIFF), then the image will not be displayed even if the memory stream contains a valid data.
In this case, you might need to use a programming toolkit that supports loading this type of images, convert it to one of the natively supported formats such as JPEG, PNG, BMP, etc. And then show it in the Microsoft .NET Picture Box control.
Rafnas T PPosted May 3, 2018, 1:46 PM
Amit GuptaPosted May 3, 2018, 5:23 AM
Sai YangPosted May 3, 2018, 5:19 AM
Amit GuptaPosted May 3, 2018, 5:07 AM
Sai YangPosted May 3, 2018, 4:53 AM
Amit GuptaPosted May 3, 2018, 4:08 AM
Piyush PansuriyaPosted May 3, 2018, 3:05 AM
Sai YangPosted May 3, 2018, 1:58 AM
Sai YangPosted May 3, 2018, 1:57 AM
Amit GuptaPosted May 3, 2018, 1:08 AM
Amit GuptaPosted May 3, 2018, 1:07 AM
Piyush PansuriyaPosted May 3, 2018, 12:57 AM
Sai YangPosted May 3, 2018, 12:35 AM
Sai YangPosted May 3, 2018, 12:33 AM
Piyush PansuriyaPosted May 2, 2018, 11:30 PM