...

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



chris_angell
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=" & _
Server.MapPath("database\eShopV8_pp.mdb")

' 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

%>

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

<%
rs1.moveNext
CountLines = CountLines + 1
loop
end if

' Closing the database
rs1.Close
Set rs1 = Nothing
%>

many thanks chris

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

if Not rs1.eof AND Not rs1.bof then

BarrMan
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum