donb1
asked on
View picture from Access database
I use the following to view Access database text items:
MySQL = "SELECT * FROM tAddress "
Set dbtemp = OpenDatabase(dbname)
Set rst = dbtemp.OpenRecordset(MySQL )
ID = rst("ID")
Last = rst("Last")
First = rst("First")
List1.AddItem Last & First
rst.Close
My database has a picture in a picture field. What code do I use to display that picture in an image box?
MySQL = "SELECT * FROM tAddress "
Set dbtemp = OpenDatabase(dbname)
Set rst = dbtemp.OpenRecordset(MySQL
ID = rst("ID")
Last = rst("Last")
First = rst("First")
List1.AddItem Last & First
rst.Close
My database has a picture in a picture field. What code do I use to display that picture in an image box?
Can pictureboxes be data bound? IF so, just set the datasource to the field in your database. Otherwise, hmm. I don't know. I've never tried that.
You've stored picture as OLE object in MSAccess in LongBinaryFormat. This can be read using a DATAControl + ImageBox linked to that database-table-field and not by using DAO.
Take a look at the AppendChunk / GetChunk example in VB Help. (at least in VB5 Help). It shows an example using of displaying an image from a DB.
Note that loading a picture requires it to either be in a file, or in the Clipboard. I can't find a way to put the data straight from a variable onto the clipboard, so you need to write a file out to do this.
Note that loading a picture requires it to either be in a file, or in the Clipboard. I can't find a way to put the data straight from a variable onto the clipboard, so you need to write a file out to do this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
mark2150
Sounds good, but How do I make a pointer?
Sounds good, but How do I make a pointer?
ASKER
mark2150's comment is more relevant, but I need to know how to make a pointer.
Pointer is simply path to file; N:\IMAGES\ABC123.JPG or in UNC notation (preferred) \\Server\Drive\Dir\File.ex t
Field is straight ASCII.
Control.LoadPicture trim("" & rs!pointer)
M
Field is straight ASCII.
Control.LoadPicture trim("" & rs!pointer)
M
ASKER
Thanks
No problem. This Q comes up all the time. I've designed image processing systems for Sheriff's Departments and Jails and they have hundreds of thousands of images being updated continuously. Keeping images IN the database simply isn't practical.
M
M