...

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



chris_angell
09-01-2007, 01:06 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
%>

Spudhead
09-01-2007, 02:07 PM
What line is giving you the error message?

I wouldn't try generating a random number from your recordcount before you've checked that you've got a populated recordset to count.

chris_angell
09-01-2007, 02:33 PM
hello... on PWS .. it is not giving a specific error line number.. i get this..(



HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services

Technical Information (for support personnel)

* Error Type:
ADODB.Field (0x80020009)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/2fifty/featuredArtists.asp

* Browser Type:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6

* Page:
GET /2fifty/featuredArtists.asp

* Time:
01 September 2007, 14:31:34

* More information:
Microsoft Support

miranda
09-05-2007, 11:29 PM
Did you solve the problem? If not it could be that you are on the last record in the table when you display the 1st random record, then when you try to move to the next one there is no more records therefore the error.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum