I want to save an image from a picturebox in the form to the database and read it again from the database to the picturebox. I try to use [PictureBox.Image.Save(<MemoryStream>, PictureBox.Image.RawFormat)] but I got an error. How to do it?
Printable View
I want to save an image from a picturebox in the form to the database and read it again from the database to the picturebox. I try to use [PictureBox.Image.Save(<MemoryStream>, PictureBox.Image.RawFormat)] but I got an error. How to do it?
What sort of database is it?
Also, what is the exact code that you are using and what is the error?
I use SQL database and this is the code I found in VS 2003
It works good in VS 2003 but the same concept in VS 2005 make an error Message "A generic error occurred in GDI+."Code:MemoryStream ms = new MemoryStream();
PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat);
byte[] arrImage = ms.GetBuffer();
// Close the stream object to release the resource.
ms.Close();
I don't want to make a binding controls to the database but I just want to save the picture from the picturebox to the field image in the database and retrieve it again later.
"PictureBox1.Image.RawFormat"
I've got such problem once
Try using another format, like JPeg or Bmp. I guess that fixed it