My database is SQL Server. In that one photo data column is there. That is varbinary datatype. How to retrieve the original image from that code. Please suggest any better way
Regards, Pradeep
My database is SQL Server. In that one photo data column is there. That is varbinary datatype. How to retrieve the original image from that code. Please suggest any better way
Regards, Pradeep
VarBinary is binary - so cast the field in the resultset to byte[]
byte[] bytes = (byte[])dataReader["fieldname"];
Then use a MemoryStream to convert the bytes to Image
public Image BytesToImage(byte[] bytes)
{
using(MemoryStream ms = new MemoryStream(bytes))
{
Image image = Image.FromStream(ms);
return image;
}
}