Solved

View picture from Access database

Posted on 2000-03-28
9
285 Views
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
rst.Close

My database has a picture in a picture field.  What code do I use to display that picture in an image box?
0
Comment
Question by:donb1
[X]
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
9 Comments
 
LVL 1

Expert Comment

by:jamauss
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.
0
 

Expert Comment

by:yuvaraj
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.
0
 
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.
0
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

by:
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.

M
0
 

Author Comment

by:donb1
ID: 2665700
mark2150
  Sounds good, but How do I make a pointer?
0
 

Author Comment

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

Expert Comment

by:mark2150
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)

M
0
 

Author Comment

by:donb1
ID: 2669130
Thanks
0
 
LVL 12

Expert Comment

by:mark2150
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.

M
0

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