I am working on a Student Management System through windows form application. I need to store and retrieve student images to my database. I am getting an error
invalid parameter
every time I try to retrieve data from the SQL table. There might be error on the image storing procedure. Please help me out.
Here is my save and retrieve code:
Image img = Image.FromFile(ofd.FileName);
byte[] imageData;
using (MemoryStream ms = new MemoryStream())
{
img.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
imageData = ms.ToArray();
}
and then I'm concatenating imageData
to my sqlString
.
And retrieving code:
byte[] arr = (byte[])dgv.Rows[e.RowIndex].Cells["memberImage"].Value;
MemoryStream str = new MemoryStream();
int offset = 78;
str.Write(arr, offset, arr.Length - offset);
Image img = Image.FromStream(str);
pbShowImage.Image = img;
This could be asked many time, but I'm getting a little frustrated on searching and implementing and getting again and again the same error