View Full Version : random error BOF or EOF is True.. how can i remove it

09-01-2007, 01:09 PM
I have some code that makes random records appear from the database.. but the lower error message is coming up... and i am not to sure how to get over it.. i have tried if not(rs1.eof OR rs1.bof) then .. but didn't work.. this error only comes up now and again... ??? please view my code below..

ADODB.Field (0x80020009)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.


' Connection string and SQL statement
Dim query, connStr
query = "select * from Artists"
connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _

' Opening database
Dim rs1
Set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.Open query, connStr, 3, , adCmdText

' Generating random number from total number of records
Dim intRnd, CountLines
Randomize Timer
intRnd = (Int(RND * rs1.RecordCount))

' Now moving the curs1or to random record number
CountLines = 0

if not(rs1.eof OR rs1.bof) then
rs1.Move intRnd
do until CountLines = 2

' Showing the random statement


<td class="MnText"><a class="GreyLnkSm" href="Artists.asp?ID=<%= rs1("ID")%>"><%= rs1("Name")%></a></td>

CountLines = CountLines + 1
end if

' Closing the database
Set rs1 = Nothing

many thanks chris

09-14-2007, 04:13 PM
try this:

if Not rs1.eof AND Not rs1.bof then

09-14-2007, 04:53 PM
This kind of error shows up when you're trying to request information from an unknown record in your database. Make sure that record exists and also your statement is wrong. You should change it to AND NOT Rs.BOF.