Read OLE Object field to Image ?

  • Thread starter Thread starter Sandi
  • Start date Start date
S

Sandi

I have a simple problem:
I have an Access database (images.mdb) that has 2 columns: one is the id if
the picture (an integer) and one (column named picture) is a field of type
OLE Object which contains an image (it can store jpg, bmp, gif, but I don't
know what image is stored inside).
I want to retrieve the picture stored in the database and identified by a
given id and display it in a web page (.aspx).
I write in Visual C#, but it does not matter, VB answers are just as
wellcome.
My problem is that this OLE Object field does not contain just the raw array
of bytes that form the image. So I can not just read the array of bytes and
output it to the browser.
no, it contains some extra information about the type of the file stored
(which would be good to know so I can know what kind of image it is). but I
don't know how to get this information.
I also don't know how to separate this information from the actual image.
Does anyone know how to solve this ?
 
I would like to thank you for your help.
But my problem reffers to something else.
I have no problem in reading the db field where the image is stored as an
OLE object.
I read it ok and I obtain an array of bytes.
BUT. This array of bytes that I read is NOT the actual image!
The problem si that the byte array is made of a header (of variable length)
that is added by Access and then it is continued with the actual image
information.
This is the way an OLE Object is stored. this is the way Access stores
images - as OLE Objects that are different from the actual image (the image
is preceded by a header).
So:
- does anyone know how I can parse this byte array into header + image (so I
can obtain the image) - the header seems to be of variable lenghth...
- or... is there any component (control) that I can use from Visual Studio
that can read the OLE Object (the byte array) and return me the image that
is wrapped inside the OLE Object ?
 
Hi Sandi,

Sorry about that. I didn't look closely enoough at the article. I have seen
this before, and thought that the article I pointed to described this, but I
was mistaken. Check out the following article instead, which should have
enough information for you to parse out the header:

http://support.microsoft.com/defaul...port/kb/articles/q175/2/61.asp&NoWebContent=1

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
 
Back
Top