I'm getting GDI+ error when saving picturebox image to the database. My database is sql server with image datatype. Ideally when I browse image file to the picturebox then save using following code

MemoryStream ms = new MemoryStream();
      picMenu.Image.Save(ms, picMenu.Image.RawFormat);
      Dim arrImage() As Byte = ms.GetBuffer
      ms.Close();

then it works fine. when I bring back the same image from the database to picturebox and then re-save using the same code it gives me GDI+ exception. Does anyone have any clue why this would happen.

Would Image format be changed? I have also tried gif, jpeg etc image format.. but i get same error.

I got this error too. This solution helps me. Saving the picture with the different tag name properties.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.