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 4 of 4
  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
    %>
    <marquee>thanks</marquee>

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    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.

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    Brighton, UK
    Posts
    282
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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
    <marquee>thanks</marquee>

  • #4
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,062
    Thanks
    4
    Thanked 8 Times in 8 Posts
    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.


  •  

    Posting Permissions

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