exporting blobs from access to xml

W

wphx

Hi,

I hope someone can help me. I'm going a bit crazy. I have a data base with
images for personel records which have been imported into an "ole object"
field in access tables. I imported these using the adodb.stream object. It
all works fine.

Now,

when I export to xml using microsoft's built-in procedure "ExportXML"
everything works nicely, the jpeg data exported in bin.base64, I can cut and
paste into another xml sheet, and render it to firefox with
data:image/jpeg;base64,<.....> ot works fine

when I have written my own procedure to populate the xml export, i try to
retrieve the binary data, using adodb.stream (.write the contents of the
field in the buffer, and then use .read to bring the contebnts into a
variant). I then use a proceudre to convert the variant into a base64
string, and I get a very different set of data, which is not recognised as a
..jpeg when rendering it to firefox.

can anyone help me? I'm wondering whether the binary data has been
encapsulated in something (or not) which microsoft is automatically
extracting and I'm not?

does anyone have any clues?

Thank you for your help
 
W

wphx

Here is some code. I would've expected varStream to have the same binary
data as the .jpg file but it doesn't. Sourec.jpg and target.jpg are the
same.


Public Function demostream() As Variant

Dim mstream As ADODB.Stream
Dim f As String
Dim r As ADODB.Recordset
Dim varStream As Variant
Dim sql As String

'
'
Set r = New ADODB.Recordset
sql = "SELECT * FROM ImgDetails"
r.Open sql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic

f = "source.jpg"
Set mstream = New ADODB.Stream
mstream.Type = adTypeBinary
mstream.Open
mstream.LoadFromFile f
'
r.MoveFirst
'
r.Fields("ImgBinary").Value = mstream.Read
r.Update
Set mstream = Nothing
'
r.MoveFirst
Set mstream = New ADODB.Stream
mstream.Type = adTypeBinary
mstream.Open
mstream.Write r!ImgBinary
mstream.SaveToFile "target.jpg"
varStream = mstream.Read
'

End Function
 

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