Moving through a recordset

Results 1 to 2 of 2

Thread: Moving through a recordset

  1. #1
    Join Date
    Dec 1969

    Default Moving through a recordset

    I hope this is not a very common question :) I need to allow the user to navigate through the recordset one record at a time. I have provided next and previous buttons. The scheme I used is not an efficient one but I couldn't think of anything else. On Next button click, I reopen the same page with '1' as parameter. It opens the connection and recordset, and applies .movenext once to get to the required record. It used to work, but doesn't do anymore. I am using cursor type 1 here (what SET is that???) Please help. Thanks.

  2. #2
    Join Date
    Dec 1969

    Default this is the *MOST* common question

    Or if it isn&#039;t, it almost is.<BR><BR>Unfortunately, there are MANY answers to it, and some of them are pretty bad answers.<BR><BR>Your scheme woudn&#039;t be bad *IF*:<BR><BR>(1) You make sure to open the recordset with adOpenStatic for the cursor type.<BR>(2) You do RS.MaxRecords=1 to make sure you aren&#039;t buffering more records than are needed.<BR>(3) You use RS.MOVE (instead of using RS.MoveNext multiple times). (You could also look at RS.AbsolutePosition)<BR><BR>So:<BR>&#060;%<BR>...< BR>Set RS = Server.CreateObject("ADODB.Recordset")<BR>RS.Open "yourTableNameOrSQLquery", yourConnection, adOpenStatic<BR>RS.MaxRecords = 1<BR>RS.CacheSize = 1 &#039; probably not necessary, but can&#039;t hurt<BR>RS.AbsolutePosition = Request("whichRecord")<BR>...<BR>%&#062;<BR><BR>Re cords are numbered starting at 1 when you use AbsolutePosition.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts