Solved

"Rowset does not support fetching backward"

Posted on 2003-11-26
6
1,484 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Query Join 9 61
How to get statistic's from a competitors website?! 1 85
Need to rewrite code for checking if a file exists 3 57
Using Classic ASP inside HTML pages 2 55
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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/…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

919 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now