I am new to asp so please forgive me if the solution to this problem is obvious.
I have two asp pages, index.asp and detail.asp. index.asp queries an access database then writes text with a link to the second page. When the link is followed an id # is passed to the second page. detail.asp then queries the database using the id# and writes the results.
The first page is working correctly, but the second is giving me troubles. I think the problem is in how ive written the query. At first i was getting a type mismatch error. Now I am getting an error that says "Item cannot be found in the collection corresponding to the requested name or ordinal".
The code is as follows
From index.asp
<%
'Define variables and initialize database connection:
Dim adoCon 'Holds the Database Connection Object
Dim rsReadDetail 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query to query the database
Dim ID 'Variable to pass ItemID to next page
Set adoCon = Server.CreateObject("ADODB.Connection")'Create an ADO connection object
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("auction.mdb")'Set an active connection to the Connection object using a DSN-less connection
Set rsReadDetail = Server.CreateObject("ADODB.Recordset") 'Create an ADO recordset object
'strSQL variable with an SQL statement then open recordset: "other" items "rank=2"
strSQL = "SELECT qryDetail.ItemID, qryDetail.Item From qryDetail WHERE (((qryDetail.RankID)=2));"
rsReadDetail.Open strSQL, adoCon'Open the recordset with the SQL query
'Loop through recorset and display "minor" items
Do While not rsReadDetail.EOF
'display the current record in the recordset
Response.Write ("• ")
Response.Write ("<a href='detail.asp?ID=")
Response.Write (rsReadDetail("ItemID"))
Response.Write ("'>")
Response.Write (rsReadDetail("Item"))
Response.Write ("</a>")
Response.Write ("<p>")
rsReadDetail.MoveNext
Loop
'Close recordset and clear string
adoCon.close
Set rsReadDetail = Nothing
set adoCon = Nothing
%>
From detail.asp
<%
'Define variables and initialize database connection:
Dim adoCon 'Holds the Database Connection Object
Dim rsReadDetail 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query to query the database
Set adoCon = Server.CreateObject("ADODB.Connection")'Create an ADO connection object
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("auction.mdb")'Set active connection to Connection object using a DSN-less connection
Set rsReadDetail = Server.CreateObject("ADODB.Recordset")'Create an ADO recordset object
strSQL = "SELECT qryDetail.ItemID, qryDetail.Image, qryDetail.Item, qryDetail.Description, qryDetail.Value, qryDetail.CurrentBid, qryDetail.MinimumBid From qryDetail WHERE ItemID='"&Request.Querystring("ID")&"';"
'display the current record in the recordset
Response.Write ("<img src='images/")
Response.Write (rsReadDetail("Image"))
Response.Write ("' border='0' align='absbottom'>")
Response.Write ("<p>")
Response.Write (rsReadDetail("Item"))
Response.Write ("<br>")
Response.Write (rsReadDetail("Description"))
Response.Write ("<p>")
Response.Write("<strong>")
Response.Write (rsReadDetail("Value"))
Response.Write ("<Br>")
Response.Write ("Current Bid $")
Response.Write (rsReadDetail("CurrentBid"))
Response.Write ("<Br>")
Response.Write ("<a href='bid.asp'>Bid Now</a>")
Response.Write ("</Strong>")
Response.Write ("<hr width='100%' size='1' noshade color='#df8422'>")
Response.Write ("<p>")
'Close recordset and clear string
adoCon.close
Set rsReadDetail = Nothing
set adoCon = Nothing
%>
Thanks in advance for any advice.
Ed.
I have two asp pages, index.asp and detail.asp. index.asp queries an access database then writes text with a link to the second page. When the link is followed an id # is passed to the second page. detail.asp then queries the database using the id# and writes the results.
The first page is working correctly, but the second is giving me troubles. I think the problem is in how ive written the query. At first i was getting a type mismatch error. Now I am getting an error that says "Item cannot be found in the collection corresponding to the requested name or ordinal".
The code is as follows
From index.asp
<%
'Define variables and initialize database connection:
Dim adoCon 'Holds the Database Connection Object
Dim rsReadDetail 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query to query the database
Dim ID 'Variable to pass ItemID to next page
Set adoCon = Server.CreateObject("ADODB.Connection")'Create an ADO connection object
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("auction.mdb")'Set an active connection to the Connection object using a DSN-less connection
Set rsReadDetail = Server.CreateObject("ADODB.Recordset") 'Create an ADO recordset object
'strSQL variable with an SQL statement then open recordset: "other" items "rank=2"
strSQL = "SELECT qryDetail.ItemID, qryDetail.Item From qryDetail WHERE (((qryDetail.RankID)=2));"
rsReadDetail.Open strSQL, adoCon'Open the recordset with the SQL query
'Loop through recorset and display "minor" items
Do While not rsReadDetail.EOF
'display the current record in the recordset
Response.Write ("• ")
Response.Write ("<a href='detail.asp?ID=")
Response.Write (rsReadDetail("ItemID"))
Response.Write ("'>")
Response.Write (rsReadDetail("Item"))
Response.Write ("</a>")
Response.Write ("<p>")
rsReadDetail.MoveNext
Loop
'Close recordset and clear string
adoCon.close
Set rsReadDetail = Nothing
set adoCon = Nothing
%>
From detail.asp
<%
'Define variables and initialize database connection:
Dim adoCon 'Holds the Database Connection Object
Dim rsReadDetail 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query to query the database
Set adoCon = Server.CreateObject("ADODB.Connection")'Create an ADO connection object
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("auction.mdb")'Set active connection to Connection object using a DSN-less connection
Set rsReadDetail = Server.CreateObject("ADODB.Recordset")'Create an ADO recordset object
strSQL = "SELECT qryDetail.ItemID, qryDetail.Image, qryDetail.Item, qryDetail.Description, qryDetail.Value, qryDetail.CurrentBid, qryDetail.MinimumBid From qryDetail WHERE ItemID='"&Request.Querystring("ID")&"';"
'display the current record in the recordset
Response.Write ("<img src='images/")
Response.Write (rsReadDetail("Image"))
Response.Write ("' border='0' align='absbottom'>")
Response.Write ("<p>")
Response.Write (rsReadDetail("Item"))
Response.Write ("<br>")
Response.Write (rsReadDetail("Description"))
Response.Write ("<p>")
Response.Write("<strong>")
Response.Write (rsReadDetail("Value"))
Response.Write ("<Br>")
Response.Write ("Current Bid $")
Response.Write (rsReadDetail("CurrentBid"))
Response.Write ("<Br>")
Response.Write ("<a href='bid.asp'>Bid Now</a>")
Response.Write ("</Strong>")
Response.Write ("<hr width='100%' size='1' noshade color='#df8422'>")
Response.Write ("<p>")
'Close recordset and clear string
adoCon.close
Set rsReadDetail = Nothing
set adoCon = Nothing
%>
Thanks in advance for any advice.
Ed.