Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2004
    Posts
    11

    Question Unanswered: Error MSG config when no data found by query. EOF BOF true

    This is the error msg
    **************
    ADODB.Field error '80020009'

    Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

    /members/logon/main.asp, line 0
    ***************

    This is my code
    **************
    <%
    sqlrs2="SELECT * FROM customers WHERE (ID ="&Session("UID").Item("ID") &") ORDER BY AutoNumber desc"
    Dim pPath2
    vPath2 = "../../fpdb/tree_service_entry.mdb"
    pPath2 = Server.MapPath( vPath2 )

    DIM objConn2
    Set objConn2 = Server.CreateObject("ADODB.Connection")
    objConn2.ConnectionString= "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & pPath2 & ";" & "JET OLEDBatabase Password=house2456"
    objConn2.Open

    DIM objRS2
    Set objRS2 = Server.CreateObject("ADODB.Recordset")
    objRS2.Open sqlrs2, objConn2
    %>

    <%
    If objRS2.eof or objRS2.bof then
    Response.write("No Data")
    Else
    End If
    %>

    <%=objRS2("AutoNumber")%>

    <%
    objRS2.Close
    Set objRS2 = Nothing
    %>

    <%
    objConn2.Close
    Set objConn2 = Nothing
    %>

    ****************

    Seems that my IF objRS2.eof or objRS2.bof then statements are wrong. Whit it set up like this the error Text (No Data) will write to the page above the Database error msg. I know that I am just typing something wrong.

    In my results I do not want it to loop, I just want one record (the largest autonumber)

    Any assisance is greatly appreciated

    Thanks

  2. #2
    Join Date
    May 2004
    Posts
    125
    The problem isn't with your check for eof or bof but the code afterwards. No matter what your if statement is(True or False) you still write out the autonumber from your query. Try this code instead:

    <%
    If objRS2.eof or objRS2.bof then
    Response.write("No Data")
    Else
    Response.write objRS2("AutoNumber")
    End If
    %>

    <%
    objRS2.Close
    Set objRS2 = Nothing
    %>

    <%
    objConn2.Close
    Set objConn2 = Nothing
    %>

  3. #3
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    And shouldn't the IF statement be an "AND"?

    If objRS2.eof AND objRS2.bof Then...

    When a recordset is empty, it is both Begining of File and End of File... it's how I've always done it.. maybe it's just a sanity check...
    That which does not kill me postpones the inevitable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •