Opening/Saving Images To DB With VBA

jaythom

New member
Local time
Today, 16:47
Joined
Aug 16, 2003
Messages
7
I want to be able to import images into my database. I have been successful in setting up an OLE box that allows me to copy&paste an image into the field. However, I have not been able to save that image to a database via ADO. I have been trying to save it like I would save text:

Dim con as New ADODB.Connection
Dim rst as New ADODB.Recordset
set con = CurrentProject.Connection
Set rst = New ADODB.Recordset
rst.open "SQL",etc.
rst.AddNew
Me.OLEImage = rst.Fields("OLEfield")
rst.update
rst.close
etc.

I do not understand why this does not work. I have been able to use images when using no code (having Access' arrows on the bottom to move around), but I require the use of ADO to save/etc.

Does anyone have any suggestions on how to do this, where to go to find out more? I have searched for the past two weeks on the internet, but have not found anything that works. Just some VB6 code that references ADO Control something (I know VBA fairly well, but still more to learn).

Any suggestions would be great!

Thanks!

John
 
Its not considered good practice to store images in your db as it is a major source of db bloat.

the usual practice is to store the images in a folder and store a link to the images in a table. I'm sure I've seen some examples out there. If I find one I'll post a link.
 
I thought it would be on Roger's site:

Roger Says:

It is usually preferable NOT to store OLE objects like pictures in the table itself. It causes massive database bloat. The usual solution is to store the pictures as files on the hard drive and store the file name in the table. This sample demonstrates how to to this.

Find this example on this page:
Pictures2k.mdb (161 KB) ( beginner ) Access 2000
 

Users who are viewing this thread

Back
Top Bottom