none
Rowset does not support fetching backward.

    Question

  • Hi,

     

    I get the following error.

    Err.Description - "Rowset does not support fetching backward."

    Err. Number - -2147217884

     

    Can somebody tell me the reason behind this error.

     

    My Reasearch: I have got to know that I get this error in the line of code recordset.MoveLast in My code.

     

    My Code environment: I have built an SQL Query string which calls the Strored procedure with one parameter (parameter tyoe is string type). I have attached the SP code below.

     

    and SP contains the call for querying other database in the same server using OPENQUERY command.

     

    and the VB code contains code as Recordset.MoveLast. (Error is generated here and Recordset.RecordCount is also -1)

     

    SP code is:

     

    Code Block

    CREATE PROCEDURE [dbo].[sp_RMS]

    @sRMS_Status CHAR(12)

    AS

    BEGIN

    DECLARE @sSQL VARCHAR (1000)

    SET @sSQL = '''SELECT *

    FROM VW_JOKE

    WHERE JOKE_ID = ''' + '''' + @sRMS_Status + '''' +

    ''' ORDER BY JOKE_NO''

    EXEC ( 'SELECT * FROM OPENQUERY(lnk_joke__cat,' + @sSQL + ')' )

    END

     

     

    My Questions:

    1). Is there any problem in SP as I am using OpenQuery? I queries the SP and concluded that it generates result properly.

     

    2). Is there any problem with the Recordset.MoveLast line?  I am using adOpenKeyset, adLockReadOnly as parameters to my Recordset.Open command along with other parameters.

     

    Let me know the corrective steps to be taken to get rid of this error.

     

    Thanks in Advance for your valuable time

    Ranjan Jain

    Saturday, December 29, 2007 3:07 PM

Answers

  • Try to set "CursorLocation" property of your record set to "adUseClient" (before opening the recordset). This might fix the problem. It might also fix the problem of recordcount showing up as -1
    Sunday, December 30, 2007 8:10 AM
    Moderator

All replies

  • Try to set "CursorLocation" property of your record set to "adUseClient" (before opening the recordset). This might fix the problem. It might also fix the problem of recordcount showing up as -1
    Sunday, December 30, 2007 8:10 AM
    Moderator
  • This worked quite nicely! Do you mind sharing documentation on the matter?

    9 years later, your comment helped :)

    So to be more specific, I was working on excel 2013 using DAO to query excel files. I needed to get the number of records in the record-set and had the same error with the function:

    recordset.MoveLast

    The error was:

    Err.Description - "Rowset does not support fetching backward."

    So I tried your suggestion and it worked fine. Thanks.




    Tuesday, November 01, 2016 6:35 PM