I am completely new to ASP and no wonder it is proving challenging.
I am writing a small application that enables users search for courses...unfortunately am getting an error I can't resolve as show below together with the asp code (error first followed by asp code). I need help. Thanks.
# Error Type:
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.
/asp/isy5v98_find_details.asp, line 60
# Browser Type:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1
# Page:
POST 59 bytes to /asp/isy5v98_find_details.asp
# POST Data:
selectedcourseno=isy320&selectedyear=1999&selected term=fall
# Time:
Friday, March 23, 2007, 3:53:19 PM
# More information:
Microsoft Support
The asp code is below:
<html>
<title>
Search Result
</title>
<body>
<%
'========================================
'Define an ADO connection object
Dim connection
Set connection = Server.CreateObject("ADODB.Connection")
'=======================================
'Define a connection string and set its value
Dim connectionstring
connectionstring = "dsn=oracle_student1_dsn; pwd=nathan"
'=======================================
'Open the connection to the database using the connection string information
connection.open connectionstring
'=======================================
'Define an ADO recordset object that will contain rows retrieved from query
Dim objRS
Set objRS = Server.CreateObject("ADODB.Recordset")
'=======================================
'Define a variable to store the query and create the query
Dim strSQL
if len(trim(request("selectedyear"))) < 1 then
strSQL = "select * from section s, course c" & _
" where s.courseno = '" & request("selectedcourseno") & _
"' and term = '" & request("selectedterm") & _
"' and s.courseno = c.courseno;"
else
strSQL = "select * from section s, course c" & _
" where s.courseno = '" & request("selectedcourseno") & _
"' and year = " & trim(request("selectedyear")) & _
" and term = '" & request("selectedterm") & _
"' and s.courseno = c.courseno;"
end if
'=======================================
'Open the recordset object to run the query and retrieve the recordset
objRS.Open strSQL, connection
'if no records returned, then inform the user
if objRS.eof then
response.write ("Course Not Found")
else
'as long as there are records, process them
do while not objRS.eof
'return info on each course to the browser
response.write ("Call Number: " & objRS("callno") & "<br>")
response.write ("Course Number: " & objRS(1) & " " & objRS("name") & "<br>")
response.write ("Term: " & objRS("term") & "<br>")
response.write ("Year: " & objRS("year") & "<br>")
response.write ("Time: " & objRS("time") & "<br>")
response.write ("Days: " & objRS("days") & "<br>")
response.write ("Room Number: " & objRS("roomno") & "<br>")
response.write ("Maximum Number of Students Allowed in Class: " & objRS("maxallowed") & "<br>")
response.write ("Instructor's ID: " & objRS("prof_id") & "<br>")
response.write ("************************************************ ****" & "<br>")
'move the pointer to the next row in the recordset
objRS.movenext
'loop back to process the next row
loop
end if
'come here when EOF reached
'done processing rows
'==============================
'close recordset and connection objects
objRS.close
set objRS = nothing
'==============================
connection.close
set connection=nothing
'==============================
'end vbscript code
%>
</body>
</html>