Solved

ADODB.Field Error '8002009'

Posted on 2004-10-07
13
1,790 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

626 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