ASP getRows problem - Requested operation requires a current record

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TimSki
    New Member
    • Jan 2008
    • 83

    ASP getRows problem - Requested operation requires a current record

    Hi,

    This is very strange...

    I have a simple query using a recordset thus...
    Code:
     
    set rsID = CreateObject("ADODB.recordset") 
    searchPhrase = "SELECT blah...."
    rsID.Open searchPhrase, oConn
     
    If NOT (rsID.eof AND rsID.bof) then
    myArray = rsID.getRows()
    End If
    Occasionally this code generates an error on the myArray line as follows...

    'Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record'

    How is that possible since i've already made that check before calling getRows ???

    Any help would be much appreciated !

    Thanks.
    Last edited by DrBunchman; Jun 2 '08, 09:09 AM. Reason: Added code tags - Please use the # button
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi TimSki,

    When this error occurs have you been able to see whether there is anything different about this recordset - e.g. does it contain zero rows?

    Have you been able to recreate the error at will?

    Dr B

    Comment

    • TimSki
      New Member
      • Jan 2008
      • 83

      #3
      Hi Dr B,

      Thanks for your reply.

      I thought the eof/bof check confirms it has no rows....

      So far i haven't been able to recreate this at will.

      Comment

      • DrBunchman
        Recognized Expert Contributor
        • Jan 2008
        • 979

        #4
        Originally posted by TimSki
        I thought the eof/bof check confirms it has no rows....
        Yes it should but while we don't know what's behind the error it makes sense to check all the circumstances that may be causing it.

        If you could run the query generated by your code in Query Analyzer or similar you would be able to see whether a recordset is being returned or not. If it isn't then it may suggest that your EOF or BOF check is not working properly.

        If a recordset is being returned by the query then perhaps the problem lies with the getRows line. You could comment that out and try a simple Response.Write rsID("value1") instead and see if that errors.

        Dr B

        Comment

        • jhardman
          Recognized Expert Specialist
          • Jan 2007
          • 3405

          #5
          I believe if you type it this way "if not (rs.eof AND rs.bof)" you evaluate false only if you have both EOF and BOF at the same time, and that will never happen. Try instead:
          [code=asp]if not rs.eof and not rs.bof[/code]or
          [code=asp]if rs.eof or rs.bof
          response.write "no records returned"
          else
          myArray = rsID.getRows()
          end if[/code]let me know if this helps.

          jared

          Comment

          • TimSki
            New Member
            • Jan 2008
            • 83

            #6
            thanks for all your help. I've made the changes you suggest which will hopefully solve the problem.

            Comment

            Working...