| Author |
Topic Search Topic Options
|
pjb007
Groupie
Joined: 03 September 2004
Location: United Kingdom
Status: Offline
Points: 185
|
Post Options
Thanks(0)
Quote Reply
Topic: Displaying image using database Posted: 27 May 2005 at 12:13pm |
I have an access database one of the fields is called images.
I have tested the database connecting works be displating the AutoNum data so I know that the connection string works.
in the images field there are filepaths to images
/images/image1.gif
/images/image2.gif
/images/image3.gif
/images/image4.gif
/images/image5.gif
For Example.
However when I write the ASP to display the image they won't display.
This is the current code I am using
Response.Write ("<p/>") %> <img src="images/ <% Response.Write (RSUser("image")) %>" > <%
|
I have tried a few others but can't get it to work.
|
 |
dj air
Senior Member
Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
|
Post Options
Thanks(0)
Quote Reply
Posted: 27 May 2005 at 12:55pm |
<% Response.Write ("<p/>") %> <img src="images/<%= RSUser("image") %>" >
try that
|
 |
pjb007
Groupie
Joined: 03 September 2004
Location: United Kingdom
Status: Offline
Points: 185
|
Post Options
Thanks(0)
Quote Reply
Posted: 27 May 2005 at 1:01pm |
I assume I need to reopen the ASP so add a <% to the end, tried both.
Error Type: Microsoft VBScript compilation (0x800A0400) Expected statement /tv/test.asp, line 47 <%Response.Write ("<p/>")
|
 |
dj air
Senior Member
Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
|
Post Options
Thanks(0)
Quote Reply
Posted: 27 May 2005 at 1:03pm |
|
can we see the whole code around the area and also post whats on line 47 and aroun d those lines.
|
 |
pjb007
Groupie
Joined: 03 September 2004
Location: United Kingdom
Status: Offline
Points: 185
|
Post Options
Thanks(0)
Quote Reply
Posted: 27 May 2005 at 1:21pm |
dj air wrote:
<% Response.Write ("<p/>") %> <img src="images/<%= RSUser("image") %>" >
|
try that
|
Its working now, just spotted what was wrong the first<% was already open, just deleted it and the images are now displaying!
Edited by pjb007 - 27 May 2005 at 1:22pm
|
 |
pjb007
Groupie
Joined: 03 September 2004
Location: United Kingdom
Status: Offline
Points: 185
|
Post Options
Thanks(0)
Quote Reply
Posted: 27 May 2005 at 3:12pm |
Well it works to a point then fails.
<%
dim Conn dim FilePath dim SQL Dim RsUser
'Connection to Database
Set Conn = Server.CreateObject("ADODB.Connection") FilePath = Server.MapPath("db.mdb") Conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & FilePath & ";"
'SQL Query String
SQL = "Select image FROM tbltest ORDER By num"
'Set the Recordset
Set RSUser = Conn.Execute (SQL)
'Print the Recordset
RSUser.movefirst Do while not RSUser.EOF
'Response.Write("num")
Response.Write ("<p/>") %> <img src="images/<%= RSUser("image") %>" > <%
Response.Write "<br/>"
'Response.Write ("</p>")
RSUser.movenext
Loop
%>
|
Is there anything missing in the above, Does the connection to the database need to be closed, I am not sure how you do that 100%.
Edited by pjb007 - 27 May 2005 at 3:22pm
|
 |
dj air
Senior Member
Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
|
Post Options
Thanks(0)
Quote Reply
Posted: 27 May 2005 at 3:57pm |
try
<%
dim Conn dim FilePath dim SQL Dim RsUser
'Connection to Database
Set Conn = Server.CreateObject("ADODB.Connection") FilePath = Server.MapPath("db.mdb") Conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & FilePath & ";"
'SQL Query String
SQL = "Select image FROM tbltest ORDER By num"
'Set the Recordset
Set RSUser = Conn.Execute (SQL)
'Print the Recordset
RSUser.movefirst Do while not RSUser.EOF
'Response.Write("num")
Response.Write ("<p/>") response.write ("<img src=""images/" & RSUser("image") &""" >")
Response.Write "<br/>"
'Response.Write ("</p>")
RSUser.movenext
Loop
%>
|
the above looks fine. the above that i pasted also is just a response.write version..
what problem are you getting
|
 |
pjb007
Groupie
Joined: 03 September 2004
Location: United Kingdom
Status: Offline
Points: 185
|
Post Options
Thanks(0)
Quote Reply
Posted: 27 May 2005 at 5:01pm |
OK its working, and displaying everything proberly. However once the page has loaded, if I het F5 to refresh it does not display and gives this error.
Error Type: Provider (0x80004005) Unspecified error /tv/test.asp, line 32
Here is a screen shot of the code 
%>
Sorry cut that off the end!
Edited by pjb007 - 27 May 2005 at 5:07pm
|
 |