Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

"Rowset does not support fetching backward"

Posted on 2007-11-27
4
Medium Priority
?
1,296 Views
Last Modified: 2013-12-25
Hi,

The following snippet of code results in error "Rowset does not support fetching backward", in particular the .MoveLast line.

Does anybody see why?

The 2 key elements I am after here are 1) setting the CursorType to adOpenStatic in order to have the RecordCount be set, and 2) use CopyFromRecordSet (b/c I find it very convenient)

Thank you in advance for your advice.

Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    rs.CursorType = adOpenStatic
   
    With rs
        .ActiveConnection = cn
        Dim sql As String
        .Open "exec sproc " 'sql
        Sheet4.Range("A" & CStr(FIRST_ROW)).CopyFromRecordset rs
        .MoveLast
        recCnt = rs.RecordCount
        ' MsgBox "Rec Cnt " + CStr(rs.RecordCount)
        .Close
    End With
   
    cn.Close
    Set rs = Nothing
    Set cn = Nothing

Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    rs.CursorType = adOpenStatic
    
    With rs
        .ActiveConnection = cn
        Dim sql As String
        .Open "exec sproc " 'sql
        Sheet4.Range("A" & CStr(FIRST_ROW)).CopyFromRecordset rs
        .MoveLast
        recCnt = rs.RecordCount
        ' MsgBox "Rec Cnt " + CStr(rs.RecordCount)
        .Close
    End With
    
    cn.Close
    Set rs = Nothing
    Set cn = Nothing

Open in new window

0
Comment
Question by:DotTheBug
3 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20361393
>        Sheet4.Range("A" & CStr(FIRST_ROW)).CopyFromRecordset rs
will consume your recordset.
you probably don't need the .movelast at all...

0
 

Author Comment

by:DotTheBug
ID: 20366793
CursorLocation = clientSide did the trick.
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 21638908
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question