0

i have a database with an image filed.I have read this Image field and convert to byte array with code below.

imageByte = ((dtgrid.CurrentRow.Cells[2].Value) as System.Data.Linq.Binary).ToArray();

When I Create a stream and Assign it to PictureBox image like this:

 MemoryStream ms = new MemoryStream(imageByte);
            pictureBox1.Image = Image.FromStream(ms);

I have this error:

Parameter is not valid.

How Can I fix this.

user3319756
  • 61
  • 1
  • 1
  • 8
  • Maybe try one of these? http://stackoverflow.com/questions/9576868/how-to-put-image-in-a-picture-box-from-a-byte-in-c-sharp – KSib Aug 31 '16 at 21:02
  • This is most likely to be because `imageByte` does not actually contain valid image data. Have you verified that it is, in fact, a valid image, before loading it into the picture box? – Martin Aug 31 '16 at 21:03
  • 1
    Martin@You say the right thing.thank u.data was wrong.i fix it – user3319756 Aug 31 '16 at 21:09

0 Answers0