Database BLOBs with OLE wrappers

G

Guest

I have a web application where users can upload JPG image files which I store
as BLOBs in a SQL Server database. This works fine in general. However, I
like to use MS Access to browse and occasionally manually update the database
for administrative purposes. The JPG images do not display in Access. The
reason is that Access expects images to be wrapped in some kind of OLE
envelope. Does anyone know what .NET class I can use to create the envelope
that Access expects? Thanks!
 
P

Patrice

Try http://support.microsoft.com/kb/q158941/

But you'll have then likely to undo that (stripping this "prefix") when you
need this image in your final application ! My personal preference would be
to stay away from this... You could likely have some code to extract the raw
image and display it on an Access form (either directly if possible or by
dumping the content to a file).

As a side note, IMO images are most often stored as a link to an external
file and included in the DB only when finding a very valid reason to do
this...

Patrice
 
C

Cor Ligthert

Steve,

I thought there was as well a thirth format, what I do not know, however
makes this little snippet one clear to you?

\\\
Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader()
rdr.Read()
Dim arrImage() As Byte = DirectCast(rdr.Item("Photo"), Byte())
Dim ms1 As New System.IO.MemoryStream(arrImage, 78, arrImage.Length - 78)
Dim origimage As System.drawing.Image = System.Drawing.Image.FromStream(ms1)
///

With this you can read the samples from the Northwind database, I assume
they are OLE.

Cor
 
G

Guest

Cor,

Thanks, I'll give it a try soon. The Image class documentation doesn't
directly mention the OLE wrapper, however I noticed that on the FromStream
method you DO NOT have to specify a format, so the wrapper must be there,
otherwise it wouldn't know whether to interpret it as JPG/GIF/etc.
 
P

Paul Clement

¤ I have a web application where users can upload JPG image files which I store
¤ as BLOBs in a SQL Server database. This works fine in general. However, I
¤ like to use MS Access to browse and occasionally manually update the database
¤ for administrative purposes. The JPG images do not display in Access. The
¤ reason is that Access expects images to be wrapped in some kind of OLE
¤ envelope. Does anyone know what .NET class I can use to create the envelope
¤ that Access expects? Thanks!

No because the OLE header information is specific to the application for which the OLE blob is being
stored. There is no direct support for OLE in .NET.

Better to save the BLOB to a file and then launch the native application to make any changes. When
you're finished update the BLOB in the database from the modified file.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top