Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 18th, 2007, 01:34 PM
Authorized User
 
Join Date: Feb 2007
Location: , , United Kingdom.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to dhillon555
Default help with image display

hi guys i am trying to display a image for each record in my database but i am having trouble this is the code i am using can anybody help

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Orders</title>
<link href="project.css" rel="stylesheet" type="text/css">
</head>
<body>
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsOrder 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query to query the database

'Create an ADO connection object
Set adoCon =Server.CreateObject("ADODB.Connection")

'Set an active connection to the connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("order.mdb")


'Create an ADO recordset object
Set rsOrder = Server.CreateObject("ADODB.Recordset")

'Initalise the strSQL variables with an SQL statement to query the database
strSQL = "SELECT tblOrders.Firstname, tblOrders.Surname, tblOrders.Telno, tblOrders.Cardno, tblOrders.Item, tblOrders.Itemcode, tblOrders.Qty FROM tblOrders;"

'Open the recordset with the SQL query
rsOrder.Open strSQL, adoCon

'Loop through the recordset

Do While not rsOrder.EOF

'Write the HTML to display the current record in the recordset
    Response.Write ("<h1>Order</h1>")
    Response.Write ("<br>")
    Response.Write("Firstname: ")
    Response.Write (rsOrder("Firstname"))
    Response.Write ("<br>")
    Response.Write("Surname: ")
    Response.Write (rsOrder("Surname"))
    Response.Write ("<br>")
    Response.Write("Telephone: ")
    Response.Write (rsOrder("Telno"))
    Response.Write ("<br>")
    Response.Write("Card Number: ")
    Response.Write (rsOrder("Cardno"))
    Response.Write ("<img src='..\images<%=rsOrder("Itemcode")%>'>")
    Response.Write ("")

    'Move to the next record in the recordset
    rsOrder.MoveNext

Loop

'Rest server objects
rsOrder.Close
Set rsOrder = Nothing
Set adoCon = Nothing
%>

</body>
</html>

Reply With Quote
  #2 (permalink)  
Old February 18th, 2007, 02:49 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,105
Thanks: 1
Thanked 63 Times in 63 Posts
Send a message via AIM to dparsons
Default

<%=rsOrder("Itemcode")%> dont do this, as the response lines are wrote to the browser AFTER execution of the page has completed hence that code will never be executed. In your loop you need ot do something like:

Response.wrie("<img src='../images" & rsOrder("Itemcode") & "'>")

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html

Discussion:
http://p2p.wrox.com/topic.asp?TOPIC_ID=56429
Reply With Quote
  #3 (permalink)  
Old February 18th, 2007, 08:59 PM
Authorized User
 
Join Date: Feb 2007
Location: , , United Kingdom.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to dhillon555
Default

Quote:
quote:Originally posted by dparsons
 <%=rsOrder("Itemcode")%> dont do this, as the response lines are wrote to the browser AFTER execution of the page has completed hence that code will never be executed.††In your loop you need ot do something like:

Response.wrie("<img src='../images" & rsOrder("Itemcode") & "'>")

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html

Discussion:
http://p2p.wrox.com/topic.asp?TOPIC_ID=56429
Reply With Quote
  #4 (permalink)  
Old February 18th, 2007, 09:01 PM
Authorized User
 
Join Date: Feb 2007
Location: , , United Kingdom.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to dhillon555
Default

hi my friend, that code has brought up and image for each record but the image is not displaying, the thing I am trying to do is relate a image path which is writen in a database filed to the bring up the image by using the path if you get what i mean

Reply With Quote
  #5 (permalink)  
Old February 19th, 2007, 12:14 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,105
Thanks: 1
Thanked 63 Times in 63 Posts
Send a message via AIM to dparsons
Default

if your database already stores the relative path to the image then all you need to do is:

<img src='" & rsOrder("Itemcode") &"'>"

that will display your image.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html

Discussion:
http://p2p.wrox.com/topic.asp?TOPIC_ID=56429
Reply With Quote
  #6 (permalink)  
Old February 19th, 2007, 01:03 PM
Authorized User
 
Join Date: Feb 2007
Location: , , United Kingdom.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to dhillon555
Default

thanks you my friend you have cracked it for me i was wondering if you could help me with one more thing how would i define the size of the image

Reply With Quote
  #7 (permalink)  
Old February 19th, 2007, 01:09 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,105
Thanks: 1
Thanked 63 Times in 63 Posts
Send a message via AIM to dparsons
Default

Thats basic html. Alter the image tag accordingly.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html

Discussion:
http://p2p.wrox.com/topic.asp?TOPIC_ID=56429
Reply With Quote
  #8 (permalink)  
Old February 19th, 2007, 01:11 PM
Authorized User
 
Join Date: Feb 2007
Location: , , United Kingdom.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to dhillon555
Default

i have tried doing that but i keep getting errors


Reply With Quote
  #9 (permalink)  
Old February 19th, 2007, 01:12 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,105
Thanks: 1
Thanked 63 Times in 63 Posts
Send a message via AIM to dparsons
Default

What errors.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html

Discussion:
http://p2p.wrox.com/topic.asp?TOPIC_ID=56429
Reply With Quote
  #10 (permalink)  
Old February 19th, 2007, 01:18 PM
Authorized User
 
Join Date: Feb 2007
Location: , , United Kingdom.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to dhillon555
Default

Error Type:
Microsoft VBScript compilation (0x800A03EE)
Expected ')'
/pro/order.asp, line 49, column 50
Response.Write("<img src= '" & rsOrder("Itemcode")WIDTH=105 HEIGHT=97 & "'>")

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Upload image-create & save thumbnail-display image angshujit ASP.NET 2.0 Professional 6 July 11th, 2013 10:34 PM
Display of image sanjay mishra .NET Web Services 4 September 15th, 2009 12:41 AM
How to Display the image from the image field. mikeparams SQL Server 2000 1 October 29th, 2004 02:23 AM
upload/display image alitoday Classic ASP Basics 4 June 28th, 2004 01:33 AM
display an image gorney .NET Web Services 0 December 29th, 2003 12:52 PM



All times are GMT -4. The time now is 02:27 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.