How to show a picture from sql server( BLOB type )

My table has a blob type field,it's a "*.jpg" picture
how can I show it in control picturebox

I use System.Drawing.Image.FromStream(stream),but it's error why

Pls help me about blob

my code is from vs.net sdk,it's good,but it's not showing in picturebox!


Answer this question

How to show a picture from sql server( BLOB type )

  • moker

    to further optimize this, you can cut out the Memory Stream and convert directly from byte[] by using the ImageConverter.ConvertFrom method.
  • Oleg Starodumov

    Nice...never knew there was an ImageConverter.  
  • leafnode

    The idea is to move the bytes to a Bitmap via a stream.

    byte[] b = (byte[])myDataSet.Tables[0].Rows["MyPictureField"];
    if (b != null)
    {
    if(b.Length > 0)
    {
    MemoryStream ms = new MemoryStream(b);
    bmp = new Bitmap(ms);
    ms.Close();
    }
    }

  • How to show a picture from sql server( BLOB type )