Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

embeded image in access database

Status
Not open for further replies.

timdodgson

Technical User
Jun 12, 2000
111
0
0
GB
Any help would be greatly appreciated i have tryed this binarywrite but i am sure ut is just me in th access database the ole image says bitmap image i have 5k records so i hope i can find a soultion or its a lot of work
Many Thanks in Advance


Tim Dodgson
 
Do you need to store the image in the db, or are you just trying for fun? If possible, It's usually preferable to save the images in the filesystem and just store the link info in the db.

I'm not sure what you are exactly asking. You don't want it to say bitmap, or are you having problems actually getting the image in there?
 
You can put the binary bitmap in a field of the .mdb. You can find the code to do so in www. However, I like the way travisbrown said: just save the bitmaps in a folder and save the paths in the field of the .mdb.
 
Thanks very much for the replies
I will try to be a bit clearer
I have an access database with over 5000 records in which i have inhereted
what i wood like to do is display some of the info in a web page
I have done this with all the fields except for the embed images
So basicly i want to display an embed image from an access database in a browser

Any help would be greatly appreciated

many Thanks in advance
Tim
 
Couple of ways of doing this:

1. Content Type and Binary Write

Create a file called getPic.asp. This file will be ASP code only (no HTML) and will need to set the contenttype to image/jpeg (or whatever the format is). The page should accept a value in the querystring to represent the id of the image you want to use (e.g. the guid of the row, or other unique id)

The code then needs to get the image data from the database - don't use ODBC if you can help it ( - for DSN-less connections) and pull back ONLY the image data from the database. You can either use GetRows (which will pull the whole blob data in one go, but will usually circumnavigate BLOB retrieval issues, or you can use GetChunk method of the recordset object.

Then use BinaryWrite to output the binary data of the image. This is the only data you want to output in this page. So whenever you call getPic.asp it will respond with an image. Your code to show a picture in your html page would look something like:

[tt]<img src="/dir/path/getPic.asp?id=123" alt="example" />[/tt]

This will allow you to show picture data from the database inside any page you want.

2. Export to File Based Images

The easiest and most common way is to use files from the OS for images, and just store the links to the files in the db. If you wanted you could run a one time process to export all of these images to the OS. You can use the above method, and just replace the output to the page with the filesystemobject, as long as you record the location/name of the file in the source db. This will mean you can use the simpler route of file based images rather than db based.


Hope that helps,

A smile is worth a thousand kind words. So smile, it's easy! :)
 
Thanks for the replie
This gives me a good overviewof the steps i have todo

I have searched the microsoft kb and found the following articlae that i must do

q175261

would this be the best way and can any body help with vb as i have never used it

Many Thanks
Tim
 
Hey. Not too sure if this is what you want but it sounds like it.

<img src = "<%= (recordset.Field("Image").Value) %>" >

Where "Image" is the name of column holding the image paths in the db. And well recordset... you should have some idea.

It works but if you can't get it to, let me know i'll post a full sample code.

+-------------------+
| IMAGE |
|```````````````````|
| /images/image.jpg |
|___________________|
 
Whoops sorry this isn't embedded... But this is a easier way and saves on db size too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top