Image Load From Database Cant Load
Hello everyone who codes. I have a winform appliacation uses Fast Report. In database i have bitmap column for storing image data as byte[]. So in fast report i need to some code works. I have and empty picturebox and i want it to fill with image data from database on creating report. Problem is that i am saving my report informations and after creating record, i will show informations in report works fine. After then if i would want to change to record i am opening record with modify and after modifiying i want to show report again and this time report does not work. Same code gives exception TargetInvocationException when i use report.Prepare() or report.Show()
Here is my code i used in report file
This is my converting function
public Bitmap ByteToImage(byte[] blob)
{
MemoryStream mStream = new MemoryStream();
byte[] pData = blob;
mStream.Write(pData, 0, Convert.ToInt32(pData.Length));
Bitmap bm = new Bitmap(mStream, false);
mStream.Dispose();
return bm;
}
private void _StartReport(object sender, EventArgs e)
{
Picture3.Image = (Image)ByteToImage(((Byte[])Report.GetColumnValue("Table.Resim"))) ;
}
Here is my code i used in report file
This is my converting function
public Bitmap ByteToImage(byte[] blob)
{
MemoryStream mStream = new MemoryStream();
byte[] pData = blob;
mStream.Write(pData, 0, Convert.ToInt32(pData.Length));
Bitmap bm = new Bitmap(mStream, false);
mStream.Dispose();
return bm;
}
private void _StartReport(object sender, EventArgs e)
{
Picture3.Image = (Image)ByteToImage(((Byte[])Report.GetColumnValue("Table.Resim"))) ;
}
Comments
attach bytearray image to pictureobject
BTW, have you ever tried this?
bind picture3 using datacolumn property => Picture3.DataColumn = "Table.Resim"