0

I need some help retrieving image [binary data] stored in a posgresql database column and displaying it in the pictureBox in C#. I inserted it using MemoryStream.

Thanks!

  • Make sure you set the memorystream position to zero after writing and before reading. The reading may fail if your graphic card doesn't support the graphic mode of the image. I would try saving picture to a file. The open file with your image view on machine to check if image is good. – jdweng Feb 20 '21 at 11:54

1 Answers1

0

I found a solution.

byte[] imgdata = (byte[])dataGridView1.CurrentRow.Cells[1].Value;
MemoryStream ms = new MemoryStream(imgdata);
pictureBox.Image = Image.FromStream(ms);

Thanks jdweng for dropping a comment.