Go Back  DVD Talk Forum > General Discussions > Tech Talk
Reload this Page >

Access OLE OBJECT field to JPG

Tech Talk Discuss PC Hardware, Software, Internet and Other Technology

Access OLE OBJECT field to JPG

Old 09-11-03, 09:19 AM
  #1  
DVD Talk Legend
Thread Starter
 
Join Date: Feb 2003
Posts: 14,204
Likes: 0
Received 1 Like on 1 Post
Access OLE OBJECT field to JPG

Has anyone ever succesfully written code to convert images stored in an Access OleObject field to saved JPGs? I tried one program from http://www.lebans.com/oletodisk.htm only to have it generate error messages as it tried to save.

(Maybe this is because I am using Windows XP? I'll test this on a 2000 machine...)

So does anyone have any advice, other than "right-click and save as"?
Old 09-11-03, 11:30 AM
  #2  
X
Administrator
 
X's Avatar
 
Join Date: Oct 1987
Location: AA-
Posts: 10,948
Received 48 Likes on 39 Posts
I know it's possible because I've read jpgs in and out of Access and SQL Server databases. It's been some years though and I don't remember how I did the writing to a file.
Old 09-11-03, 11:53 AM
  #3  
DVD Talk Gold Edition
 
Join Date: Jun 2001
Location: Not There...
Posts: 2,596
Likes: 0
Received 0 Likes on 0 Posts
I have some VB code somewhere that will do this. I'll see if I can find it.
Old 09-11-03, 11:54 AM
  #4  
DVD Talk Legend
Thread Starter
 
Join Date: Feb 2003
Posts: 14,204
Likes: 0
Received 1 Like on 1 Post
Usually, I turn to Google groups and find the answers that way, but they are no help whatsoever. There are various GetChunk and AppendChunk methods that will create a JPG file, but these for whatever reason are inoperable and unrecognizable.

If that helps at all.
Old 09-11-03, 12:04 PM
  #5  
DVD Talk Gold Edition
 
Join Date: Jun 2001
Location: Not There...
Posts: 2,596
Likes: 0
Received 0 Likes on 0 Posts
Are the jpgs stored as binaries in the DB?
Old 09-11-03, 12:09 PM
  #6  
DVD Talk Gold Edition
 
Join Date: Jun 2001
Location: Not There...
Posts: 2,596
Likes: 0
Received 0 Likes on 0 Posts
I don't remember if this worked, but I do remember spending hours on trying to figure it out. This should save the jpg file to whatever path you give it.

Code:
Dim picture() As Byte

'open db, find field
recordset.Open query, connection
recordset.MoveFirst

'put together jpg, save to file
Do Until recordset.EOF
  Redim picture(recordset("fieldname").ActualSize - 1)
  picture = recordset("fieldname").GetChunk (recordset("fieldname").ActualSize)
  SaveBinToFile picture, filename
  recordset.MoveNext
Loop

recordset.Close

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Thread Tools
Search this Thread

Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service - Do Not Sell My Personal Information -

Copyright 2021 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.