Access 2007 Attachment Image Display Problem (1 Viewer)

rgraham

New member
Local time
Today, 07:37
Joined
May 12, 2009
Messages
2
I'm new to this forum, so apologize in advance if this issue has already been answered in another thread.

I'm trying to display jpg images which have been stored in an "attachment" type field in Access 2007. The data base is currently residing on the server, and I'm using ASP to establish a connection and make a sql type query to select the desired record. So far, the connection and query work fine, and when I display the data as text instead of as an image, the jpg data appears to have been found with no problem. The issue occurs when I try to use the asp file as an image source in html I have only been able to get an "X" box, instead of the image.

The asp method that I am using is:

<%
'Declare Variables..
Dim sql
Dim rs
Dim conn
Dim userID
Dim mpath
Dim str
'Instantiate Objects
mpath=Server.MapPath("\")&"\Directory\"
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider = "Microsoft.ACE.OLEDB.12.0"
conn.Properties("Data Source") =mpath & "DataBaseName.accdb"
conn.Open
set rs = Server.CreateObject("ADODB.recordset")
'Get the specific image based on the ID passed in a querystring
str = "SELECT Picture.[FileData] FROM PlayerData WHERE PlayerData.[ID]=2389"

rs.Open str, conn,3,3
if rs.eof then 'No records found
rs.close
conn.close
set rs = Nothing
set conn = Nothing
Response.End
else 'Display the contents
Response.ContentType = "image/jpeg"
Response.BinaryWrite (rs("Picture.FileData"))
end if

rs.close
conn.close
set rs = Nothing
set conn = Nothing
%>

(In this case the file was named "Showpicture6.asp" and the ID=2389 record was fixed for testing purposes)

In the html file the following image tag was used:

<img src="Showpicture6.asp">

Anythoughts as to where I'm going wrong. (Sorry for the long post)
Bob
 

Users who are viewing this thread

Top Bottom