Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 24th, 2003, 08:19 PM
Authorized User
 
Join Date: Jun 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Moving around a recordset

Hi guys, I'm having difficulty with navigating a recordset, hopefully someone out there can point me in the right direction.

I have 4 links that will allow a user to view the First, Previous, Next, and Last record in a recordset,

When a button is clicked it reloads the page and send through the querystring a value of first, previous, next, or last.

I use these values in an If statement, as follows...
Code:
'Move to first, last, next or Previous record
IF moveMe = "first" THEN
  Rs.MoveFirst
  Location = 1
ELSEIF moveMe = "next" THEN
  Rs.MoveNext
  Location = Location + 1
ELSEIF moveMe = "prev" THEN
  Rs.MovePrevious -1
  Location = Location - 1
ELSEIF moveMe = "last" THEN
  Rs.MoveLast
  Location = Counter
END IF
Location is the name of a variable that (believe it or not) holds the exact location of the recordset.

In my adovbs.inc file I have set adOpenForwardOnly = 1

MoveNext, and Movefirst both work fine, but movePrevious and MoveLast have different errors, they are...

movePrevious => Wrong number of arguments or invalid property assignment: 'Rs.MovePrevious'
moveLast => Rowset does not support fetching backward.

Any help here would be much appreciated.

Cheers,

Blaise
 
Old June 24th, 2003, 08:27 PM
Authorized User
 
Join Date: Jun 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

instead of using adOpenForwardOnly...
try adOpenStatic or adOpenDynamic...
im not exactly sure which would be best but...

this will allow you to move around the record set in any way you want..
adOpenForwardOnly only allows forward movement

hope this helps
 
Old June 24th, 2003, 08:32 PM
Friend of Wrox
 
Join Date: May 2003
Posts: 202
Thanks: 0
Thanked 1 Time in 1 Post
Default

I don't have my books with me right now, so this may not be quite correct.

I think the problem is with how you defined the cursor. By setting it to adOpenForwardOnly you create a cursor that cannot move backwards (hence why it says "ForwardOnly" :D).

Instead, try setting it to adOpenStatic.

Bruce Luckcuck
Director, Applications & Support Services
Wiley Publishing, Inc.
 
Old June 24th, 2003, 08:38 PM
Authorized User
 
Join Date: Jun 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I also have the other two Constants declared, they are set to...

Const adOpenDynamic = 2
Const adOpenStatic = 3

I'm not entirely sure what the values 2, and 3 mean, I've tried looking about, but can't seem to find anything, I find the Microsoft site really damn confusing.
 
Old June 24th, 2003, 08:46 PM
Authorized User
 
Join Date: Jun 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

These are just ado constants...
they are given names like adOpenForward only so that is is easier to understand what they do...
for example..
objRS.CursorType = adOpenForwardOnly
is easier to understand than
objRS.CursorType = 0
 
Old June 24th, 2003, 08:52 PM
Authorized User
 
Join Date: Jun 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I just realised I was getting confused, thinking that the constants were switches, but are infact variables, so I eventually opened my recordset as a dynamic recordset, and it works fine now, thanks for giving my brain a jig, I needed it.

If you guys know where I can get some good online information about these ADO variables, could you let me know.

Cheers,

Blaise
 
Old June 25th, 2003, 06:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:
If you guys know where I can get some good online information about these ADO variables, could you let me know.
http://www.devguru.com/Technologies/...ado_intro.html





Similar Threads
Thread Thread Starter Forum Replies Last Post
Clone DAO Recordset into ADO Recordset kamrans74 VB How-To 0 March 6th, 2007 11:57 AM
Query from Recordset into another Recordset kamrans74 Pro VB Databases 5 March 5th, 2007 04:17 PM
ADODB.Recordset (0x800A0CB3)Current Recordset does tks_muthu Classic ASP Databases 0 June 16th, 2005 07:22 AM
Convert ADO recordset to DAO recordset andrew_taft Access 1 May 5th, 2004 02:31 PM
Moving through a Recordset KeithHungate Access VBA 2 April 12th, 2004 08:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.