hope hope - 1 year ago 88
SQL Question

How to insert Image to database from picturebox

I have a

and I want to save its picture in a SQL Server database into a

Answer Source

I didnt exactly get what you meant but here is a piece of code you can use for inserting an image into database from picture box.

Image img = picturebox1.Image();
byte[] arr;
ImageConverter converter = new ImageConverter();
arr=(byte[])converter.ConvertTo(img, typeof(byte[]));

command.CommandText = "INSERT INTO ImagesTable (Image) VALUES('" + arr +    "')";
command.CommandType = CommandType.Text;