Retrieve recordset field value
I built a sql query in an ASP page that returns a single record. I'm trying to retrieve field values with no success. Can someone show me the correct syntax? In my example I'm trying to grab the Course_No value from the recordset.
Course_No = rsSelectedClass.fields("Course_No")
I get this error:
Error Type:
ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
I don't get the error if I coment it out:
Since I know the record does exist via SQL Query Manager, I must be trying to grab the field value incorrectly or something...
I'm mainly a VB6 programmer so this ASP world is new!
Thanks in advance!
Here is my code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
Dim StudentID
Dim Last_Name
Dim First_Name
Dim M_Name
Dim Course_ID
Dim Course_No
Dim Course_Section
Dim Course_Area
Dim Course_Description
Dim Course_Instructor
Dim Absence_Date
Dim Absence_Code
Dim Absence_Comments
%>
<%
StudentID = Request("StudentID")
Course_ID = Request("frmCourse_ID")
Absence_Date = Request("frmAbsence_Date")
Absence_Code= Request("frmAbsence_Code")
Absence_Comments = Request("frmAbsence_Comments")
%>
<%
Dim rsSelectedClass
Dim rsSelectedClass_numRows
Set rsSelectedClass = Server.CreateObject("ADODB.Recordset")
rsSelectedClass.ActiveConnection = MM_Data_Registrar_STRING
rsSelectedClass.Source = "SELECT SCL.Student_Id, RSL.Last_Name, RSL.First_NAME, RSL.M_NAME," & _
" CI.Area, SCL.Course_Id, SCL.Course_No, SCL.Section, SCL.Short_Description, " & _
" CI.Instructor" & _
" FROM StudentCourseList SCL INNER JOIN Course_Info CI" & _
" ON SCL.Course_Id = CI.Course_Id INNER JOIN RegStudentList RSL" & _
" ON SCL.Student_Id = RSL.STUDENT_ID" & _
" WHERE SCL.Student_Id = '" & StudentID & "'" & _
" AND SCL.Course_ID ='" & Course_ID &"'"
rsSelectedClass.CursorType = 0
rsSelectedClass.CursorLocation = 2
rsSelectedClass.LockType = 1
rsSelectedClass.Open()
rsSelectedClass_numRows = 0
Course_No = rsSelectedClass.fields("Course_No")
%>
|