Save Image

Sep 6, 2010 at 1:03 PM

Hi,

how can I save an image into this DB?

 

Thanks,

Sep 6, 2010 at 11:20 PM

I have not tried this, but did you try saving your image as byte[] (byte array)?  Please let me know if this does not work.  I would also appreciate a small repro project if this does not work for you.  I'd be glad to take a look for you. 

Thanks.

Sergey

Oct 10, 2010 at 2:47 AM
Edited Oct 10, 2010 at 3:00 AM

Hi Sergey,

Great work at first!

I'm Working on a Project in counter clock to get this ready as soon has the winPh7 goes off.

About Imaging working in XML... It cant be possibile like a MSSQL database.

Byte array... Heres the solution...

public byte[] imageToByteArray(Image imageIn)
{
MemoryStream ms = new MemoryStream(); //Here i really dont know why i cant get that memory stream
imageIn.Save(ms,System.Drawing.Imaging.ImageFormat.Gif);
return  ms.ToArray();
}

public Image byteArrayToImage(byte[] byteArrayIn)
{
     MemoryStream ms = new MemoryStream(byteArrayIn);
     Image returnImage = Image.FromStream(ms);
     return returnImage;

 

Thanks

Enxuto Out!


Oct 10, 2010 at 6:30 PM

Thanks, Marco for sample code.  The only suggestion I would make is to wrap MemoryStream inside using{} statement.