 |
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

February 18th, 2007, 02:34 PM
|
|
Authorized User
|
|
Join Date: Feb 2007
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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>
|
|

February 18th, 2007, 03:49 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
<%=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
|
|

February 18th, 2007, 09:59 PM
|
|
Authorized User
|
|
Join Date: Feb 2007
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
|

February 18th, 2007, 10:01 PM
|
|
Authorized User
|
|
Join Date: Feb 2007
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

February 19th, 2007, 01:14 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
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
|
|

February 19th, 2007, 02:03 PM
|
|
Authorized User
|
|
Join Date: Feb 2007
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

February 19th, 2007, 02:11 PM
|
|
Authorized User
|
|
Join Date: Feb 2007
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i have tried doing that but i keep getting errors
|
|

February 19th, 2007, 02:18 PM
|
|
Authorized User
|
|
Join Date: Feb 2007
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Error Type:
Microsoft VBScript compilation (0x800A03EE)
Expected ')'
/pro/order.asp, line 49, column 50
Response.Write("<img src= '" & rsOrder("Itemcode")WIDTH=105 HEIGHT=97 & "'>")
|
|
 |