ASP.NET 1.0 and 1.1 BasicsASP.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 .
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
%>
<%=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:
================================================== =========
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
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:
================================================== =========
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
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
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
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
================================================== =========
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