Pulling GIF images from an Access Database

I want to create an employee database that has info like name, extension, email, etc and a picture (gif) of the the employee.  I know how to pull text from my Access database but I don't know how to pull images.  Does anyone know of any tutorials out there that could help?  Or maybe some past experiences?
dgwestAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PBallCommented:
I think this topic has come up a lot of times before.

My suggestion, as many might have suggested before, is to keep the image outside of the database and store a pointer (filename) to the image files instead.
0
NickRackhamCommented:
dgwest

Check out my previous question http://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=10236282 

I asked exactly the same question a week or so back. Should resolve your problem.

As PBall stated above, don't try to get the imager from access but hold the images in your web in a folder called "photos" for want of a better example. then insert a column called photos in you data base and (If yor photo is called abc.gif) then enter abc in the record it relates to and have the asp page call the record write abc and then write .gif

I won't copy and paste another experts answer so check out the PAQ and all it'll cost you is 10 points.

Can't say fairer than that.

Regards

Nick
0
mgfranzCommented:
You can use three approaches to deliver the image from the database to the browser. The first way is to keep the image file on the hard drive, and store the file's name and path in the database. I don't recommend this approach, because putting the image file and its path in two different locations causes management problems. For example, if you change the filename, you must change the data entry in the database for its associated path. The second approach is to use the ASP Response object's BinaryWrite method. This method passes the image to the browser as an HTTP transaction with an HTTP header containing the IMAGE/GIF or IMAGE/JPEG type. Suppose you have a recordset named Rs that contains the image column Prod_pic in the Store database's Product table. This code demonstrates how to apply the ASP Response object's BinaryWrite method, where Cn is an instance of the ADO Connection object:


Response.Buffer = TRUE
Response.Clear
Response.ContentType = "image/gif"
Sql = "SELECT Prod_pic FROM" & _
      "Product WHERE Prod_id = 2"
Set Rs = Cn.Execute(Sql, , _ adCmdText)
Response.BinaryWrite Rs("Prod_pic")
Response.End

You must use the Response object's Clear method; otherwise users will see only ASCII in the browser, not the image. However, the Clear method erases any buffered HTML output. As a result, this piece of code displays only an image on the screen.

There's a better way to display images that allows you to have HTML together with the image. This method circumvents the management problems of image data, because it centralizes image data in the database. Use the Field object's GetChunk method in ADO to retrieve the BLOB's content. Then, save the BLOB's content to a disk file using the VB Put statement. You don't need to worry about what type of images (GIF or JPG) are stored in the database. After you create the image file, you can put its path as the SRC attribute in the IMG tag.

Mark
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

aulrichCommented:
Check out this page:

http://www.asptoday.com/articles/19990524.htm

aulrich
0
mgfranzCommented:
Aulrich,  Did you notice that the code snippet from your reference is exactly like my previous post?  Interesting...  I like the fact that everything is pretty much fully explained in detail though.

The key statement is the content type;

Response.ContentType = "image/gif"

THis is the key to posting the reference correctly,

Hope this helps.

Mark
0
dgwestAuthor Commented:
I've read that article in the past and I wasn't impressed with it.  I did get it working thanks to NickRackham's post though.  Sorry for asking a question that was previously asked and thanks for the help. Derek.
0
mgfranzCommented:
While Nick's solution is an OK one, it might create a headache later if the image directory grows to large proportions...  how will you know if an image should be deleted when an employee leaves the company.  It would be east to write a script that would delete every instance that is associated with a certain employee, including the image file.

Since you have already created a record for the file name, why not store the file itself instead of just the name?

My two cents.

Mark
0
NickRackhamCommented:
Derek,

May I post as an answer?

Nick
0
dgwestAuthor Commented:
Yep
0
NickRackhamCommented:
Many Thanks
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.