retrive image from sql express not work RRS feed

  • Question

  • User1235095465 posted

    I got the problem with retriving image and dispaly, my code is

    basically I retrive data via dataset where img_data datatype is image , but there is error:

    parameter is invalid of FromStream


    System.Drawing.Image _image = System.Drawing.Image.FromStream( new System.IO.MemoryStream( (byte[])row["img_data"] )

     anyone can help, please.

    thank you

    Monday, March 16, 2009 8:56 AM

All replies

  • User-394672074 posted

    Hi there,

    Please have a look at this code

    Note: "dt" is just a dummy DataTable, please replace accordingly.

    //DataTable dt = new DataTable();

    byte[] fileByte = null;

    fileByte = (byte[])dt.Rows(0)("Image");

    IO.MemoryStream stream = new IO.MemoryStream(fileByte);

    this._image = System.Drawing.Image.FromStream(stream);


    Hope this helps.


    Monday, March 16, 2009 9:43 AM