I have a picturebox
where custom image is drawn when mouse button is pressed now i want to save that image in SQL's image type column
.
I did search for saving but theres nothing for saving a pic from picturebox to sql image type column without url .
You could probably use this solution . Tho you would have to save the picturebox image to a jpeg first.
byte[] image = File.ReadAllBytes("D:\\11.jpg");
Edited:
//without saving the image to a physical file
MemoryStream stream=new MemoryStream();
pictureBox1.Image.Save(stream,System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] pic=stream.ToArray();
SqlCommand sqlCommand = new SqlCommand("INSERT INTO imageTest (pic_id, pic) VALUES (1, @Image)", yourConnectionReference);
sqlCommand.Parameters.AddWithValue("@Image", image);
sqlCommand.ExecuteNonQuery();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.