Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    Brighton, UK
    Posts
    282
    Thanks
    1
    Thanked 0 Times in 0 Posts

    random error BOF or EOF is True.. how can i remove it

    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
    <marquee>thanks</marquee>

  • #2
    Regular Coder
    Join Date
    Jan 2005
    Posts
    155
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try this:
    Code:
    if Not rs1.eof AND Not rs1.bof then

  • #3
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts
    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.
    Last edited by BarrMan; 09-14-2007 at 04:56 PM.


  •  

    Posting Permissions

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