Solved

View picture from Access database

Posted on 2000-03-28
9
252 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:bhess1
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

947 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now