views:

3079

answers:

3

An OLE Object column contains images but the image type (jpg/gif/tiff) is unknown. These images need to be extracted from the DB and saved to disk. The application is primarily using VB.NET but C# examples are welcome too.

thanks Rahul

+3  A: 

Try using the System.Drawing.Image.FromStream to load the image. You can make a stream from a byte array using System.IO.MemoryStream foo = new System.IO.MemoryStream(MyByteArray);

Once you've loaded the image, you can use whatever GDI stuff you want to save it (e.g. ImageInstance.Save(FileName);)

Brian
+1  A: 

Create a byte array large enough to hold the OLE object:

Dim bArr(Len(<OLE Object Field>)) as Byte

Read in the first row of your OLE Object column and place it in the Byte array.

For a GIF file, bytes 0 through 2 will have the ASCII value "GIF". For a JPEG file, bytes 6 through 9 will typically have the value "JFIF". For a PNG file, bytes 1 through 3 will have the ASCII value "PNG".

TIFF is more difficult since there are so many different TIFF standards.

Once you have determined the file type, you can use Brian's method to save the file

Stewbob
A: 

Hello! You can write an aplication to extract data from Access using free .NET library Intasphere (intasphere.ru/en/oleextract.php). It has function to extract different type of data from MS Access OLE fields.

Sergey