View picture from Access database

Posted on 2000-03-28
Last Modified: 2010-05-02
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

My database has a picture in a picture field.  What code do I use to display that picture in an image box?
Question by:donb1
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 2665292
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.

Expert Comment

ID: 2665300
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.
LVL 32

Expert Comment

by:Brendt Hess
ID: 2665323
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.
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

LVL 12

Accepted Solution

mark2150 earned 50 total points
ID: 2665626
As bhess1 said, you can't load direct from the database into the control. Thus you'll find it 2x faster to keep the image on disk and simply keep a pointer to the image file.

This Q comes up all the time and keeping images *in* a database is a bad idea. It bloats the database, slows retreival times, doesn't scale, and generally makes things cumbersome and fragile.

If you leave the images out on disk and just keep a pointer to the file you can have more images online than any single drive or server can hold and your total image store can greatly exceed what any database can hold.


Author Comment

ID: 2665700
  Sounds good, but How do I make a pointer?

Author Comment

ID: 2669067
mark2150's comment is more relevant, but I need to know how to make a pointer.
LVL 12

Expert Comment

ID: 2669117
Pointer is simply path to file; N:\IMAGES\ABC123.JPG or in UNC notation (preferred) \\Server\Drive\Dir\File.ext

Field is straight ASCII.

Control.LoadPicture trim("" & rs!pointer)


Author Comment

ID: 2669130
LVL 12

Expert Comment

ID: 2669200
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.


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month7 days, 1 hour left to enroll

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question