Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Displaying image using database
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Displaying image using database

 Post Reply Post Reply Page  12>
Author
pjb007 View Drop Down
Groupie
Groupie


Joined: 03 September 2004
Location: United Kingdom
Status: Offline
Points: 185
Post Options Post Options   Thanks (0) Thanks(0)   Quote pjb007 Quote  Post ReplyReply Direct Link To This Post 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.
 
 
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post Posted: 27 May 2005 at 12:55pm
<%
Response.Write ("<p/>") %>
<img src="images/<%= RSUser("image") %>" >

try that
Back to Top
pjb007 View Drop Down
Groupie
Groupie


Joined: 03 September 2004
Location: United Kingdom
Status: Offline
Points: 185
Post Options Post Options   Thanks (0) Thanks(0)   Quote pjb007 Quote  Post ReplyReply Direct Link To This Post 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/>")
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
pjb007 View Drop Down
Groupie
Groupie


Joined: 03 September 2004
Location: United Kingdom
Status: Offline
Points: 185
Post Options Post Options   Thanks (0) Thanks(0)   Quote pjb007 Quote  Post ReplyReply Direct Link To This Post Posted: 27 May 2005 at 1:21pm
Originally posted by dj air 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
Back to Top
pjb007 View Drop Down
Groupie
Groupie


Joined: 03 September 2004
Location: United Kingdom
Status: Offline
Points: 185
Post Options Post Options   Thanks (0) Thanks(0)   Quote pjb007 Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
pjb007 View Drop Down
Groupie
Groupie


Joined: 03 September 2004
Location: United Kingdom
Status: Offline
Points: 185
Post Options Post Options   Thanks (0) Thanks(0)   Quote pjb007 Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.