Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

View picture from Access database

Posted on 2000-03-28
9
Medium Priority
?
290 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
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 12

Accepted Solution

by:
mark2150 earned 200 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…

971 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