Click to See Complete Forum and Search --> : How View Image Stored in Access DB?


Bullschmidt
10-30-2003, 08:28 AM
A client has an OLE field called Signature in an Access database. The field contains a GIF image of a scanned signature (that a product has been received).

How can I show this image on an ASP page?

simflex
10-31-2003, 07:46 AM
are you looking to display a hyperlink to the image or do you just want to display the image?

If you are looking to display a hyperlink to the image whereby if they click on the hyperlink, the scanned picture is displayed, then try this:

select * from imageTable
Response.Write "<a href=""file.asp?ID=" & rst("ID") & """>"
Response.Write rst("picture") & "</a></td><td>"

If however, you want to display the image itself, I would try this:

<HTML>
<HEAD><TITLE>Display Image</TITLE></HEAD>
<BODY>
This page will display the picture you scanned
image field.<BR>
<IMG SRC="ShowPicture.ASP">
</BODY>
</HTML>
This calls the ASP page ShowPicture.asp which looks like this:
<%@ LANGUAGE="VBSCRIPT" %>
<%
' Clear out the existing HTTP header information
Response.Expires = 0
Response.Buffer = TRUE
Response.Clear

' Change the HTTP header to reflect that an image is being passed.
Response.ContentType = "image/gif"

Set cn = Server.CreateObject("ADODB.Connection")
' The following open line assumes you have set up a System DataSource
' by the name of myDSN.
cn.Open "accessDSN"
Set rs = cn.Execute("SELECT Picture FROM PictureTable WHERE id='0736'")
Response.BinaryWrite rs("Picture")
Response.End

Hope this helps!

Bullschmidt
10-31-2003, 07:54 AM
Thanks and that seems to work for SQL Server but unfortunately Access' OLE type field apparently is in a world of its own.