Link to home
Start Free TrialLog in
Avatar of KathrynGZ
KathrynGZ

asked on

"Rowset does not support fetching backward"

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
Avatar of Rouchie
Rouchie
Flag of United Kingdom of Great Britain and Northern Ireland image

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
ASKER CERTIFIED SOLUTION
Avatar of vijay7248
vijay7248

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vijay7248
vijay7248

KathrynGZ,

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

-Vijay
Avatar of KathrynGZ

ASKER

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
Just figured it out--a previous rs wasn't closed. So Vijay, your answer worked. Thanks much!

Kathryn
Sorry I couldn't help you out.I was at home yesterday.
Great to know you have got that to work.

-Vijay