Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ASP / Database Access / July 2006



Tip: Looking for answers? Try searching our database.

Moving to a previous record

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
James Jones - 16 Jul 2006 04:00 GMT
i know how to use rs.MoveNext to get the next record in the database. Was
wanting to know how to get the previous record.

I tried rs.MovePrevious and i get error.....

My code is as follows (the database is opened, and a query is already ran
and all)

      rs.MovePrevious
      Previous_ID = rs.Fields("id").Value
      Previous_Artist = rs.Fields("Artist").Value
      Previous_Title = rs.Fields("Title").Value
      rs.MoveNext
      rs.MoveNext
      Next_ID = rs.Fields("id").Value
      Next_Artist = rs.Fields("Artist").Value
      Next_Title = rs.Fields("Title").Value

I then get error:

ADODB.Recordset error '800a0c93'
Operation is not allowed in this context.

/playvideos.asp, line 132

any idea why?

thanks a lot!

James
Bob Barrows [MVP] - 16 Jul 2006 13:36 GMT
> i know how to use rs.MoveNext to get the next record in the database.
> Was wanting to know how to get the previous record.
[quoted text clipped - 18 lines]
> ADODB.Recordset error '800a0c93'
> Operation is not allowed in this context.

This is probably due to the cursor type you are using when opening the
recordset. The default cursor type is a firehose cursor: forward-only.

A few thoughts for you:

It is possible to construct a sql query that returns the data in the
"previous" row in the same record as the current row. Provide some details
if you wish to explore this route.

You would probably be better off using a GetRows array:
http://www.aspfaq.com/show.asp?id=2467 but choosing a different cursor type
will allow you to move backwards in the cursor. Changing CursorLocation to
client (adUseClient) will cause ADO to use the ADO Cursor Library, forcing a
static, client-side cursor which supports full navigation to be used. See
http://msdn.microsoft.com/library/en-us/ado270/htm/mdcstcursorlocationenum.asp

However, if you wish to use a server-side cursor, then set the CursorType
property to the cheapest cursor that supports the functionality you need. In
ADO, this is probably adOpenStatic. See:
http://msdn.microsoft.com/library/en-us/ado270/htm/mdmthrstopen.asp
and
http://msdn.microsoft.com/library/en-us/ado270/htm/mdcstcursortypeenum.asp

Signature

Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.