1
Answer

storing image to database

shiju kv

shiju kv

9y
577
1
i would like to store one image to databse. while inserting it shows an exception like
 
"Object reference not set to an instance of an object" in
 
 "pictureBox2.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)" this line
 
here is my code to insert 
 
MemoryStream ms = new MemoryStream();
pictureBox2.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] photo_aray = new byte[ms.Length];
ms.Position = 0;
ms.Read(photo_aray, 0, photo_aray.Length);
please help to find a solution
 
thanks 
Answers (1)