Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save Long Binary as *.jpg

Status
Not open for further replies.

tickko

Programmer
Dec 12, 2002
25
0
0
US
I have an Access DB with OLE Object fields and i'm looking for a way to export / saveas those embedded objects (pictures) as jpeg files. Is this possible to do? If so, how would I go about programming it? Can I do it in either Access or VB6?

Thanks!
 
Treat the data as an array of Bytes, and write it to a file using binary access (see open statement)
 
Only if the pictures are stored in their original long binary format in the OLE (long binary) field.
Then you would use the ADO Stream object or the GetChunk method.
If they are stored as a converted (embedded) OLE object, (via the OLE container control or in the MS ACCESS application), and not in the original binary format, then you can only use an OLE Container control to display the pictures.
You can then invoke the application associated with the file type and from there save the picture to a file.
You can save this converted OLE Object also to a file, but it can only be read as such.
There may be another method to save it in the original format. I don't know. Most users save the pictures as long binary in their original format, so you might not find alot help with this.
 
How would I determine the orginal format? I know that the pictures are embedded in the access database, because the database is offline. Would it be in the orginal format if the image will not display in a bound field in an Access form but it will display in a VB6 image field?

I have attempted to use the open statement and can get a file to export but the file will not open. "Photo Editor cannot find or open c:\text.jpg"


Dim fileNM As String
fileNM = InputBox("Enter an image filename:")
fileNM = "c:\" & fileNM

' get the current record
Dim adoRS As ADODB.Recordset
Set adoRS = adoPic.Recordset

Dim bytData() As Byte
ReDim bytData(adoRS.Fields(1).ActualSize)
bytData = adoRS.Fields(1).Value

' save
Open fileNM For Binary Access Write As #1
Put #1, , bytData
Close #1

Set adoRS = Nothing

Any ideas???

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top