Solved

"Rowset does not support fetching backward"

Posted on 2003-11-26
6
1,496 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
Technology Partners: 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Html value of radio 14 44
Display if field is NOT "" or NOT null 6 22
Record locking on classic ASP 3 40
JQuery DataTable Functionality 8 20
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 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