Search code examples
c#pictureboxnpgsqlbinary-data

Retrieve [binary data] from postgresql to pictureBox


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!


Solution

  • 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.