Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases 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
 
Old August 8th, 2005, 09:19 AM
Registered User
 
Join Date: Aug 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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")
%>


 
Old August 8th, 2005, 10:22 AM
Registered User
 
Join Date: Aug 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Looks like I got it going. I had a problem with a variable name I was passing into the form.

I have a lot to learn!


Should have been
StudentID = Request("Student_ID")
instead of
StudentID = Request("StudentID")






Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieve Autonumber field and update it carrie09 Access VBA 3 November 2nd, 2007 07:32 AM
Retrieve different data from same table /field W052107 Visual Studio 2005 7 August 6th, 2007 10:40 AM
Retrieve Field Name & Value from XML in asp andieh XML 6 October 3rd, 2006 12:52 PM
How to retrieve ID field of newly-created record Steve777 Classic ASP Professional 3 October 2nd, 2006 11:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.