Assuming you're using C# and Windows Forms, you can follow these steps:
Retrieve the image from the database as a byte array.
Convert the byte array into a MemoryStream.
MemoryStream ms = new MemoryStream(byteArray);
Use the FromStream static method of the Image class to create an Image object from the MemoryStream.
Image image = Image.FromStream(ms);
Set the Image property of the PictureBox control to the Image object.
pictureBox1.Image = image;
Here is an example code snippet:
// Assuming connection is a SqlConnection object
SqlCommand command = new SqlCommand("SELECT ImageColumn FROM Table WHERE ID=1", connection);
byte[] byteArray = (byte[]) command.ExecuteScalar();
MemoryStream ms = new MemoryStream(byteArray);
Image image = Image.FromStream(ms);
pictureBox1.Image = image;
Asked: 2022-03-29 11:00:00 +0000
Seen: 12 times
Last updated: Jul 17 '21