NickRackham
asked on
Storing Photo's in acces and displaying in ASP
I've got an Internal phone directory that our users can query and display by asp.
Part One. I would like to include a photo of each person against their record in the access database, how do I achieve this?
Part Two. How do I get this displayed in the asp page along with all the other info?, Do I just add this column to the displyed info or?????
Detailed instructions would help as I'm nearly brain dead at the moment <g>
Nick
Part One. I would like to include a photo of each person against their record in the access database, how do I achieve this?
Part Two. How do I get this displayed in the asp page along with all the other info?, Do I just add this column to the displyed info or?????
Detailed instructions would help as I'm nearly brain dead at the moment <g>
Nick
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK, I followed your above comments but the image that is being displayed is the Red Cross symbol, i.e. not available. The properties indicate that it is http://myserver/photos/.gif and not http://myserver/photos/258.gif which is my photo. The access database has a unique number as the first column, autonumber, but the column name is ID, I've tried changing the Column name but that doesn't help either.
Nick
Nick
ASKER
I've tried everything I can think of (at the moment) but whatever I do the image will not display and the properties for the error image are http://myserver/photos/.gif
Obviously not picking up the UniqueID for some reason. Please can you advise further.
I can't mail the database due to confidential data.
many thanks
Nick
Obviously not picking up the UniqueID for some reason. Please can you advise further.
I can't mail the database due to confidential data.
many thanks
Nick
OK... Can you send me the ASP page? I will see what you have and then do what I can from there...
Also, the name of trhe "unique" ID is called "ID"?
Also, the name of trhe "unique" ID is called "ID"?
ASKER
Here's the entire code for the asp page
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<base target="MAIN">
<script>
//<!--
function ShowButtons() {
if (window.top.frames.length! =0 && window.top.frames[0].ShowB uttons!=nu ll)
window.top.frames[0].ShowB uttons('/i ntr0002.ht m','/intr0 000.htm',' ','','');
}
//-->
</script>
<script language="javascript"><!--
function Title()
{
top.document.title=documen t.title;
}
//--></script>
<base target="MAIN">
<title>Phone Book Search Results</title>
</head>
<body onLoad="ShowButtons(), Title ()" text="#000000" topmargin="0" leftmargin="5"
bgcolor="#FFFFFF" link="#0000FF" vlink="#800080" alink="#FF0000">
<h2 align="center"><a name="top">Phone Book Search Results</a><small><small>< small><sma ll>
</small></small></small></ small></h2 >
<hr color="#000080">
<%
Param = Request.QueryString("Param ")
Data = Request.QueryString("Data" )
%>
<%
Session.timeout = 15
If IsObject(Session("Telephon e_conn")) Then
Set conn = Session("Telephone_conn")
Else
Set conn = Server.CreateObject("ADODB .Connectio n")
conn.open "Telephone","",""
Set Session("Telephone_conn") = conn
End If
%>
<%
sql = "SELECT PhoneBook.FirstName, PhoneBook.LastName, PhoneBook.Department, PhoneBook.Section, PhoneBook.JobTitle, PhoneBook.Location, PhoneBook.Extension, PhoneBook.DirectDial, PhoneBook.Email FROM PhoneBook WHERE (((PhoneBook.FirstName) Like '" & Request.QueryString("[Firs tName]") & "%%') AND ((PhoneBook.LastName) Like '" & Request.QueryString("[Last Name]") & "%%') AND ((PhoneBook.Department) Like '" & Request.QueryString("[Depa rtment]") & "%%') AND ((PhoneBook.Section) Like '" & Request.QueryString("[Sect ion]") & "%%') AND ((PhoneBook.Location) Like '" & Request.QueryString("[Loca tion]") & "%%') AND ((PhoneBook.Extension) Like '" & Request.QueryString("[Exte nsion]") & "%%')) "
If cstr(Param) <> "" And cstr(Data) <> "" Then
sql = sql & " And [" & cstr(Param) & "] = " & cstr(Data)
End If
Set rs = Server.CreateObject("ADODB .Recordset ")
rs.Open sql, conn, 3, 3
%>
<table BORDER="1" BGCOLOR="#FFFFFF" CELLSPACING="0" width="100%">
<font FACE="Arial" COLOR="#000000"><thead>
<tr>
</font><font COLOR="#000000"><th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000"></fo nt><font
COLOR="#000000" face="Arial" size="1">FirstName</font>< /th>
<th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000"><fon t COLOR="#000000" face="Arial" size="1">LastName</font></ th>
<th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000"><fon t COLOR="#000000" face="Arial" size="1">Department</font> </th>
<th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000"><fon t COLOR="#000000" face="Arial" size="1">Section</font></t h>
<th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000"><fon t COLOR="#000000" face="Arial" size="1">JobTitle</font></ th>
<th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000"><fon t COLOR="#000000" face="Arial" size="1">Location</font></ th>
<th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000"><fon t COLOR="#000000" face="Arial" size="1">Extension</font>< /th>
<th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000"><fon t COLOR="#000000" face="Arial" size="1">DirectDial</font> </th>
<th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000"><fon t COLOR="#000000" face="Arial" size="1">Photo</font></th>
<th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000"><fon t COLOR="#000000" face="Arial" size="1">Email</font></th>
<font FACE="Arial" COLOR="#000000">
</tr>
</thead>
<tbody>
<%
On Error Resume Next
rs.MoveFirst
do while Not rs.eof
%>
<tr VALIGN="TOP">
</font><font COLOR="#000000"><td BORDERCOLOR="#c0c0c0"></font> <font COLOR="#000000"
face="Arial" size="1"><%=Server.HTMLEnc ode(rs.Fie lds("First Name").Val ue)%><br>
</font></td>
<td BORDERCOLOR="#c0c0c0"><font COLOR="#000000" face="Arial" size="1"><%=Server.HTMLEnc ode(rs.Fie lds("LastN ame").Valu e)%><br>
</font></td>
<td BORDERCOLOR="#c0c0c0"><font COLOR="#000000" face="Arial" size="1"><%=Server.HTMLEnc ode(rs.Fie lds("Depar tment").Va lue)%><br>
</font></td>
<td BORDERCOLOR="#c0c0c0"><font COLOR="#000000" face="Arial" size="1"><%=Server.HTMLEnc ode(rs.Fie lds("Secti on").Value )%><br>
</font></td>
<td BORDERCOLOR="#c0c0c0"><font COLOR="#000000" face="Arial" size="1"><%=Server.HTMLEnc ode(rs.Fie lds("JobTi tle").Valu e)%><br>
</font></td>
<td BORDERCOLOR="#c0c0c0"><font COLOR="#000000" face="Arial" size="1"><%=Server.HTMLEnc ode(rs.Fie lds("Locat ion").Valu e)%><br>
</font></td>
<td BORDERCOLOR="#c0c0c0"><font COLOR="#000000" face="Arial" size="1"><%=Server.HTMLEnc ode(rs.Fie lds("Exten sion").Val ue)%><br>
</font></td>
<td BORDERCOLOR="#c0c0c0"><font COLOR="#000000" face="Arial" size="1"><%=Server.HTMLEnc ode(rs.Fie lds("Direc tDial").Va lue)%><br>
</font></td>
<td BORDERCOLOR="#c0c0c0"><font face="Arial" size="1"><%Response.write "<IMG SRC=""../photos/" & ID & ".gif"">" %> <br>
</font></td>
<td BORDERCOLOR="#c0c0c0"><p align="center"><font COLOR="#000000" face="Arial" size="1"><a
href="<%=rs.Fields("Email" )%>"><%if not rs.Fields("Email") = "" then%><img src="../images/mail.jpg" width="14" height="11"
border="0" alt="Click to send Email" align="middle"><%end if%></a> <br>
</font></td>
<font FACE="Arial" COLOR="#000000">
</tr>
<%
rs.MoveNext
loop%>
</tbody>
<tfoot>
</tfoot>
</table>
<hr color="#000080">
<p align="left"><a href="#top" target="_self"><img BORDER="0" SRC="../images/arrowtop.gi f"
alt="Back to Top" WIDTH="14" HEIGHT="10"></a> <font size="1"
face="Verdana,Arial,Helvet ica">Back to top</font></p>
<p align="left"><font face="Verdana" size="1">This Page was last Edited on <!--webbot
bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" --></font></p>
<p><!--"Page created by Nick Rackham"--></p>
</font>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<base target="MAIN">
<script>
//<!--
function ShowButtons() {
if (window.top.frames.length!
window.top.frames[0].ShowB
}
//-->
</script>
<script language="javascript"><!--
function Title()
{
top.document.title=documen
}
//--></script>
<base target="MAIN">
<title>Phone Book Search Results</title>
</head>
<body onLoad="ShowButtons(), Title ()" text="#000000" topmargin="0" leftmargin="5"
bgcolor="#FFFFFF" link="#0000FF" vlink="#800080" alink="#FF0000">
<h2 align="center"><a name="top">Phone Book Search Results</a><small><small><
</small></small></small></
<hr color="#000080">
<%
Param = Request.QueryString("Param
Data = Request.QueryString("Data"
%>
<%
Session.timeout = 15
If IsObject(Session("Telephon
Set conn = Session("Telephone_conn")
Else
Set conn = Server.CreateObject("ADODB
conn.open "Telephone","",""
Set Session("Telephone_conn") = conn
End If
%>
<%
sql = "SELECT PhoneBook.FirstName, PhoneBook.LastName, PhoneBook.Department, PhoneBook.Section, PhoneBook.JobTitle, PhoneBook.Location, PhoneBook.Extension, PhoneBook.DirectDial, PhoneBook.Email FROM PhoneBook WHERE (((PhoneBook.FirstName) Like '" & Request.QueryString("[Firs
If cstr(Param) <> "" And cstr(Data) <> "" Then
sql = sql & " And [" & cstr(Param) & "] = " & cstr(Data)
End If
Set rs = Server.CreateObject("ADODB
rs.Open sql, conn, 3, 3
%>
<table BORDER="1" BGCOLOR="#FFFFFF" CELLSPACING="0" width="100%">
<font FACE="Arial" COLOR="#000000"><thead>
<tr>
</font><font COLOR="#000000"><th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000"></fo
COLOR="#000000" face="Arial" size="1">FirstName</font><
<th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000"><fon
<th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000"><fon
<th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000"><fon
<th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000"><fon
<th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000"><fon
<th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000"><fon
<th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000"><fon
<th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000"><fon
<th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000"><fon
<font FACE="Arial" COLOR="#000000">
</tr>
</thead>
<tbody>
<%
On Error Resume Next
rs.MoveFirst
do while Not rs.eof
%>
<tr VALIGN="TOP">
</font><font COLOR="#000000"><td BORDERCOLOR="#c0c0c0"></font>
face="Arial" size="1"><%=Server.HTMLEnc
</font></td>
<td BORDERCOLOR="#c0c0c0"><font COLOR="#000000" face="Arial" size="1"><%=Server.HTMLEnc
</font></td>
<td BORDERCOLOR="#c0c0c0"><font COLOR="#000000" face="Arial" size="1"><%=Server.HTMLEnc
</font></td>
<td BORDERCOLOR="#c0c0c0"><font COLOR="#000000" face="Arial" size="1"><%=Server.HTMLEnc
</font></td>
<td BORDERCOLOR="#c0c0c0"><font COLOR="#000000" face="Arial" size="1"><%=Server.HTMLEnc
</font></td>
<td BORDERCOLOR="#c0c0c0"><font COLOR="#000000" face="Arial" size="1"><%=Server.HTMLEnc
</font></td>
<td BORDERCOLOR="#c0c0c0"><font COLOR="#000000" face="Arial" size="1"><%=Server.HTMLEnc
</font></td>
<td BORDERCOLOR="#c0c0c0"><font COLOR="#000000" face="Arial" size="1"><%=Server.HTMLEnc
</font></td>
<td BORDERCOLOR="#c0c0c0"><font face="Arial" size="1"><%Response.write "<IMG SRC=""../photos/" & ID & ".gif"">" %> <br>
</font></td>
<td BORDERCOLOR="#c0c0c0"><p align="center"><font COLOR="#000000" face="Arial" size="1"><a
href="<%=rs.Fields("Email"
border="0" alt="Click to send Email" align="middle"><%end if%></a> <br>
</font></td>
<font FACE="Arial" COLOR="#000000">
</tr>
<%
rs.MoveNext
loop%>
</tbody>
<tfoot>
</tfoot>
</table>
<hr color="#000080">
<p align="left"><a href="#top" target="_self"><img BORDER="0" SRC="../images/arrowtop.gi
alt="Back to Top" WIDTH="14" HEIGHT="10"></a> <font size="1"
face="Verdana,Arial,Helvet
<p align="left"><font face="Verdana" size="1">This Page was last Edited on <!--webbot
bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" --></font></p>
<p><!--"Page created by Nick Rackham"--></p>
</font>
</body>
</html>
UP here in this part of the code, you need to do this:
<%
On Error Resume Next
rs.MoveFirst
do while Not rs.eof
ID = rs("UniqueID")
%>
This will set ID to the nique ID number... Be sure to replace "UniqueID" with the appropriate field in the database.
<%
On Error Resume Next
rs.MoveFirst
do while Not rs.eof
ID = rs("UniqueID")
%>
This will set ID to the nique ID number... Be sure to replace "UniqueID" with the appropriate field in the database.
ASKER
MasseyM
I'm still getting the little red cross icon (can't display image) and when I right click to see what the properties are it reports "http://myserver/photos/.gif"
For some reason it's not picking up the ID
the path to the image is OK, the number I'm trying to call is consistent.
Any thoughts?
I'm still getting the little red cross icon (can't display image) and when I right click to see what the properties are it reports "http://myserver/photos/.gif"
For some reason it's not picking up the ID
the path to the image is OK, the number I'm trying to call is consistent.
Any thoughts?
What is the name of the field? It is hard to do this blind, so I apologize...
Basicaly, you need to set ID to equal RS("UniqueID").
Then, to check what ID equals, do this:
response.write "Current ID: " & ID
Basicaly, you need to set ID to equal RS("UniqueID").
Then, to check what ID equals, do this:
response.write "Current ID: " & ID
ASKER
No need to apologise I know what it's like <g>.
My access database has:-
ID = Autonumber
Title = Text
Forename = Text
Lastname = Text
Photo = Text (the number in this field = the ID autonumber)
More fields = Text
I have given the photo number the same as the ID autonumber as this will never change.
I take it that I need to use "photo" as the ID ? So would the relevant code above be:-
<%
On Error Resume Next
rs.MoveFirst
do while Not rs.eof
ID = rs("Photo")
%>
with the relevant table entry being:-
<td BORDERCOLOR="#c0c0c0"><font face="Arial" size="1"><%Response.write "<IMG SRC=""../photos/" & ID & ".gif"">" %> <br>
</font></td>
Hope this helps
Regards
Nick
PS. If we get really stuck I might be able to get a copy of the database, less data, and the html and asp pages mailed to you. But this may not be until tomorrow.
My access database has:-
ID = Autonumber
Title = Text
Forename = Text
Lastname = Text
Photo = Text (the number in this field = the ID autonumber)
More fields = Text
I have given the photo number the same as the ID autonumber as this will never change.
I take it that I need to use "photo" as the ID ? So would the relevant code above be:-
<%
On Error Resume Next
rs.MoveFirst
do while Not rs.eof
ID = rs("Photo")
%>
with the relevant table entry being:-
<td BORDERCOLOR="#c0c0c0"><font face="Arial" size="1"><%Response.write "<IMG SRC=""../photos/" & ID & ".gif"">" %> <br>
</font></td>
Hope this helps
Regards
Nick
PS. If we get really stuck I might be able to get a copy of the database, less data, and the html and asp pages mailed to you. But this may not be until tomorrow.
Nick,
Ok. You have a field called Photo? If so, you would use the code as you listed above. Make sure that the Photo field has a number in it though... If not, you can always use :
<%
On Error Resume Next
rs.MoveFirst
do while Not rs.eof
ID = rs("ID")
%>
Since the ID is the autonumber. Either way will work.
There is really no need to have the "photo" field since it is equal to the ID field. YOu can just use the ID field.
Ok. You have a field called Photo? If so, you would use the code as you listed above. Make sure that the Photo field has a number in it though... If not, you can always use :
<%
On Error Resume Next
rs.MoveFirst
do while Not rs.eof
ID = rs("ID")
%>
Since the ID is the autonumber. Either way will work.
There is really no need to have the "photo" field since it is equal to the ID field. YOu can just use the ID field.
ASKER
Many thanks for your perseverance. For some reason I started from scratch and it worked first time. Must have made an error that I couldn't see for looking.
Once again Thanks
Nick :o)
Once again Thanks
Nick :o)
Good deal... That sometimes happens... I start over a lot sometimes when things just aren't going right...
Good that it works...
Good that it works...
ASKER