If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Error MSG config when no data found by query. EOF BOF true

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-02-05, 23:06
rrayfield rrayfield is offline
Registered User
 
Join Date: Dec 2004
Posts: 11
Question 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
Reply With Quote
  #2 (permalink)  
Old 01-03-05, 20:48
DMWCincy DMWCincy is offline
Registered User
 
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
%>
Reply With Quote
  #3 (permalink)  
Old 01-04-05, 14:29
Seppuku Seppuku is offline
Useless...
 
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On