Solved

"Rowset does not support fetching backward"

Posted on 2003-11-26
6
1,503 Views
Last Modified: 2008-01-09
I'm using the following code in my ASP page:

Dim myConnString
Dim myConnection
Dim mySQL
      
myConnString = Application("PIA27_ConnectionString")
Set myConnection = Server.CreateObject("ADODB.Connection")

myConnection.Open myConnString

...

dim mySQL2
mySQL2 = "SELECT * FROM PIATable"
Set rs = myConnection.Execute(mySQL)
rs.movelast
do until rs.bof
response.write("blah blah")
rs.moveprevious
loop

*****
But when I view it in the browser, I get "Rowset does not support fetching backwards." It works fine if I change the code to move forward through the record set.

What do I need to change or add to get this code to work?

Thanks in advance--

Kathryn
0
Comment
Question by:KathrynGZ
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 25

Expert Comment

by:Rouchie
ID: 9829617
You need to declare a cursor type in your connection strings.  This occupies more memory on the server when queries are done, but allows more freedom in the results retrieved.

I'm a bit rusty, but something like this should do the trick;


Set myConnection = Server.CreateObject("ADODB.Connection")

' declare cursor type here before opening
myConnection.CursorType = adOpenStatic

...rest of code
0
 
LVL 3

Accepted Solution

by:
vijay7248 earned 150 total points
ID: 9829841
Hi,
myConnection.Execute(mySQL) is a ForwardOnly cursor and it does not support backward fetching.

Replace the line
         Set rs = myConnection.Execute(mySQL)
with ...
           rs.Open mySQL,myConnection,1,2

where 1 - adOpenKeyset
and 2 - adLockPessimistic

For more datails on the ADO constants please have a look at the adovbs.inc file...

Or else check this out..

http://www.codeguru.com/forum/showthread.php?threadid=266073

-Vijay

0
 
LVL 3

Expert Comment

by:vijay7248
ID: 9829984
KathrynGZ,

Do you need any more help??
Jus wondering whether your prob is solved or not

-Vijay
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:KathrynGZ
ID: 9851887
Hi Vijay,

Just got back to work after the vacation and got your solution. This is how I implemented it (hope I understood you correctly as far as the 1,2--I'm in the process of learning VBScript):

dim mySQL2
mySQL2 = "SELECT * FROM PIATable"
'Set rs = myConnection.Execute(mySQL)
rs.Open mySQL,myConnection,adOpenKeyset,adLockPessimistic
rs.movelast
do until rs.bof
response.write("blah blah")
rs.moveprevious
loop

But I got this error:

ADODB.Recordset error '800a0e79'
Operation is not allowed when the object is open.

Any suggestions?  Thanks--

Kathryn
0
 

Author Comment

by:KathrynGZ
ID: 9853802
Just figured it out--a previous rs wasn't closed. So Vijay, your answer worked. Thanks much!

Kathryn
0
 
LVL 3

Expert Comment

by:vijay7248
ID: 9855750
Sorry I couldn't help you out.I was at home yesterday.
Great to know you have got that to work.

-Vijay
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 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