Riya
Riya

Reputation: 559

How to store an image into database

How can I use openfiledialog and a picturebox and upload an image and store it into SQL Server

Upvotes: 0

Views: 283

Answers (2)

Red Swan
Red Swan

Reputation: 15553

You need to keep field datatype as varbinary(Max) in the database table. then convert image into byte array. then pass this byte array as parameter respect to your varbinary field. it will be saved in your database. while retrieving, get value from database as byte array the convert it into Image object. hope this sequence helps you. or more code example you can find here

Upvotes: 0

Adriaan Stander
Adriaan Stander

Reputation: 166546

If you g0ogled c# store image in sql, the first 2 results would have been

Store or save images in SQL Server database using C#

Store or Save images in SQL Server

Upvotes: 4

Related Questions