10 pts.
 how i do save picture in data base vb.net
iam using sql express to develop application which have i picture so i can try how a save picture inside data base and loading vb picture box can any one tell me please how i do thi?

Software/Hardware used:
ASKED: August 21, 2009  7:58 PM
UPDATED: January 23, 2010  8:16 PM

Answer Wiki:
<a href="http://msdn.microsoft.com/en-us/library/system.drawing.image.aspx">System.Drawing.Image</a> <a href="http://msdn.microsoft.com/en-us/library/system.io.memorystream.aspx">System.IO.MemoryStream</a> <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlparameter.aspx">System.Data.SqlClient</a> Use the Image class to get the file in to an image object. Use the Save method of Image to save it to a memory stream in jpeg format User memory stream's .toarray function to convert it to a byte array. Assign your database command object a parameter with the value of the byte array. execute sql of INSERT INTO table(field_name) VALUES(@byte_array_parameter_name) To get it back out: select it from the database. cast it back to a byte array use the memory stream object to convert it back to a stream. Use the image.fromstream to load it back into an image object. Set the picture boxes source to the image object.
Last Wiki Answer Submitted:  January 23, 2010  8:16 pm  by  Gent01   1,855 pts.
All Answer Wiki Contributors:  Gent01   1,855 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _