how i do save picture in data base vb.net

10 pts.
Tags:
Access Database Attachments
SQL Express
Visual Basic
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?

Answer Wiki

Thanks. We'll let you know when a new response is added.

<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.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following