Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ADODB.Field Error '8002009'

Posted on 2004-10-07
13
Medium Priority
?
1,823 Views
Last Modified: 2011-09-20
I'm getting this error on my page:

ADODB.Field error '80020009'

Either BOF or EOF is True, or the current record has been deleted; the operation requested by the application requires a current record.

I know that this error usually means that the record I'm trying to pull from a table doesn't exist or the table is empty.  But this isn't actually true in my case.

I'm trying to Pull two records from the same table.

Example:

I'd like my page to Display:

Doe, Jon A Mr. - Originator - Created Task - - 10/7/2004   <-- Line 1
Doe, Jon A Mr. - Originator - Tasked - Sample, Jane B Mrs. - Action Code - 10/7/2004  <-- Line 2
Sample, Jane B. Mrs. - Action Code - Delegated - Example, Don C. - Action Code - 10/7/2004  <-- Line 3

Etc...etc..

Everything works fine except when I try to get the second person's info from the table.  So this works:

Doe, Jon A Mr. - Originator - Created Task - - 10/7/2004 <-- Line 1
Doe, Jon A Mr. - Originator - Tasked - 1612 - Action Code - 10/7/2004 <-- Line 2

But If I try to get the name for ID 1612 is Get the ADODB.Field Error '80020009' - But the record does exist!  I doesn't work at all if I try to put a If not (not myRs.EOF AND myRs.BOF) Then into the code - then it nothing shows up.

My Code:

<!--#INCLUDE FILE="inc_Config.inc"-->
<!--#INCLUDE FILE="inc_New_Task_Header.asp"-->
<%
  'Count the Number of records in tblActionCode
   Set objConn = Server.CreateObject("ADODB.Connection")
       objConn.Open ConnString
       
   Set Rec = objConn.execute("SELECT COUNT(*) FROM tblTaskHistory WHERE TaskerID = '" & Session("TaskerID") & "'")
   
   MyCount = Rec(0)
   
%>
<TABLE Border="1" Cellspacing="0" cellpadding="0" bordercolor="#C0C0C0" bgcolor="#C0C0C0" width="65%">
  <TR>
    <TD bgcolor="#7F7F7F" colspan="2" align="center"><Font Face="Arial" Size="2" Color="White">Delegation Entries: </Font>
        <Font Face="Arial" Size="3" Color="White"><B><%=Rec(0)%></B></Font>
    </TD>
  </TR>
  <TR>
    <%
    'Database Connection to tblTaskHistory
Dim myConn
Set myConn = Server.CreateObject("ADODB.Connection")
      myConn.Open ConnString 'from your config.inc file
      mySQL = "SELECT * FROM tblTaskHistory WHERE TaskerID = '" & Session("TaskerID") & "'"
Set myRs = myConn.Execute(mySQL)
%>

      <%While Not myRs.EOF%>      
      <TD align="center">

      <%
    'Get the User's Name
    'Database Connection to tblPersonnelRoster
    Dim Pers1Conn
    Set Pers1Conn = Server.CreateObject("ADODB.Connection")
        Pers1Conn.Open ACConnString 'from your config.inc file
        Pers1SQL = "SELECT * FROM tblPersonnelRoster WHERE ID ='" & myRs("Person1ID") & "'"
    Set Pers1Rs = Pers1Conn.Execute(Pers1SQL)
      %>
                  <%
    'Get the Person2's Name
    'Database Connection to tblPersonnelRoster
    Dim Pers2Conn
    Set Pers2Conn = Server.CreateObject("ADODB.Connection")
        Pers2Conn.Open ACConnString2 'from your config.inc file
        Pers2SQL = "SELECT [Last],[First],[Grade] FROM tblPersonnelRoster WHERE ID ='" & Trim(myRs("Person2ID")) & "'"
    Set Pers2Rs = Pers2Conn.Execute(Pers2SQL)
      %>

      <%
    'Get the Action Type
    'Database Connection to tblTaskAction
    Dim ATConn
    Set ATConn = Server.CreateObject("ADODB.Connection")
        ATConn.Open ConnString 'from your config.inc file
        ATSQL = "SELECT * FROM tblTaskAction WHERE TaskActionID ='" & Trim(myRs("ActionID")) & "'"
    Set ATRs = ATConn.Execute(ATSQL)
      %>

                       <%=Pers1Rs("Last")%>,&nbsp;<%=Pers1Rs("First")%>&nbsp;
                       <%=Pers1Rs("MiddleInitial")%>,&nbsp;<%=Pers1Rs("Grade")%> -
                       <%=myRs("Person1Title")%> - <%=ATRs("TaskAction")%> -
                        <%=MyRs("Person2ID")%>
             <%=myRs("Person2Title")%> - <%=myRs("ActionDate")%>


        <%'=Pers2Rs("Last")%>  'This is causing the ERROR - If I take it out it works fine but only displays the persons
                                                       'ID instead of the Last Name

      <%myRs.movenext%><%WEND%>

<%
'Close Connection to Pers1
Pers1Rs.Close
Pers1Conn.Close
Set Pers1Conn = Nothing
Set Pers1Rs = Nothing
Set Pers1SQL = Nothing
%>
<%
  'Close Connection to Pers2
Pers2Rs.Close
Pers2Conn.Close
Set Pers2Conn = Nothing
Set Pers2Rs = Nothing
Set Pers2SQL = Nothing

  'Close Connection to ATConn
ATRs.Close
ATConn.Close
Set ATConn = Nothing
Set ATRs = Nothing
Set ATSQL = Nothing
%>

<%
  'Close Connection to tblTaskHistory
myRs.Close
myConn.Close
Set myConn = Nothing
Set myRs = Nothing
%>

      </TD>
  </TR>
</TABLE>

<%
  'Close Count Connection
  objConn.Close
  Set objConn = Nothing
  Set Rec = Nothing
%>
0
Comment
Question by:wbwillson
  • 6
  • 5
  • 2
13 Comments
 
LVL 1

Author Comment

by:wbwillson
ID: 12247105
Increased the points
0
 
LVL 14

Expert Comment

by:huji
ID: 12247149
What if you substitute this line of code:

Pers2SQL = "SELECT [Last],[First],[Grade] FROM tblPersonnelRoster WHERE ID ='" & Trim(myRs("Person2ID")) & "'"

With such:

Pers2SQL = "SELECT * FROM tblPersonnelRoster WHERE ID ='" & Trim(myRs("Person2ID")) & "'"

?? Does it help?
Huji
0
 
LVL 14

Expert Comment

by:huji
ID: 12247152
I mean why do you use those brackets (i.e. [ and ] ) in your SQL command? You don't need them! The correct format of that line is:

Pers2SQL = "SELECT Last,First,Grade FROM tblPersonnelRoster WHERE ID ='" & Trim(myRs("Person2ID")) & "'"

Wish I can help
huji
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:wbwillson
ID: 12247164
Huji,

  Thanks for the response...I originally had my SQL statement like that and it doesn't seem to matter.  I think this the error is because I'm trying to pull two different records from the same table within the same cycle.  Any other ideas?

Bill
0
 
LVL 1

Author Comment

by:wbwillson
ID: 12247173
Huji,

  Actually I do need use brackets around Last and First because those are Reserved Words within SQL Server so you must enclose them in [ ] brackets, I could leave the brackets off of the remaining fields but I find that it makes it a bit easier for me to read anyway.  The brackets don't cause any harm to the statement.

Bill
0
 
LVL 14

Accepted Solution

by:
huji earned 2000 total points
ID: 12247191
Let me say that the error occurs the ONLY time that you want to retrieve a value from Pers2Rs , isn't it true?
With your WHILE WEND loop you are just checking if myRs has not reached to the EOF. You don't check if Pers2Rs has reached to EOF, and I think that it reaches to EOF and the error is generated.
So let's check this idea:
Instead of the trouble making line:
<%'=Pers2Rs("Last")%>
Put such:
IF Pers2Rs.EOF=True THEN response.write "Huji was true!"
I'm here to see the results.
Huji
0
 
LVL 1

Author Comment

by:wbwillson
ID: 12247673
Huji,

  If I put the statement:

   IF Pers2Rs.EOF=True THEN
       response.write "Huji was true!"
   End If

within the Loop it is TRUE.  If I put it outside the Loop its FALSE.

The problem is that Pers2 is populated, it's not empty - how I can I get the data for Pers2 to show up inside the loop?

Bill
0
 
LVL 14

Expert Comment

by:huji
ID: 12247738
Send the whole code to me please. Or follow this post..
0
 
LVL 14

Expert Comment

by:huji
ID: 12247753
We first have to focus on this line of code:

 Pers2SQL = "SELECT [Last],[First],[Grade] FROM tblPersonnelRoster WHERE ID ='" & Trim(myRs("Person2ID")) & "'"

Are you sure that myRs("person2ID") contains a value that also appears on ID column of tblPersonnelRoster?
Check it out again.
Huji
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 12248474
i notice tha in ur line1, there is no id and ur code within the loop does not check for EOF or BOF .. so what heppens when within the loop, the first record tries to fetch the "Last" name for an empty id??
0
 
LVL 1

Author Comment

by:wbwillson
ID: 12249048
Rejojohny,

 Thanks for the reply.  I actually check for the existence of the ID in another page which then calls this one.  So this page would be called upon unless an ID exists.

Bill
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 12249075
i thought u were listing all the records here .. u might have to explain exactly what u r trying to do and also provide more code ..
0
 
LVL 14

Expert Comment

by:huji
ID: 12251234
Thanks for the A
Huji
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question