Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Moving to n + records


Message #1 by "Yanira" <ycastaneda@d...> on Tue, 28 Aug 2001 20:23:42
HI all 



Does anyone know how I can move to through a recordset to certain + # of 

records IE. If current record is 100 move to record 110.

I am not sure how to do this since you can only move 1 forward or back 

with the rs.MovePrevious and rs.MoveNext I tried to rs.Move (10) but this 

moves the current record; doesn't bring me the record specified.  



Thanks 
Message #2 by "Tom Small" <Tom.Small@g...> on Tue, 28 Aug 2001 22:40:43
> HI all 

> 

> Does anyone know how I can move to through a recordset to certain + # of 

> records IE. If current record is 100 move to record 110.

> I am not sure how to do this since you can only move 1 forward or back 

> with the rs.MovePrevious and rs.MoveNext I tried to rs.Move (10) but 

this 

> moves the current record; doesn't bring me the record specified.  

> 

> Thanks 



rs.Move 100 or rs.Move(100) will move you forward 100 records from that 

current record position.  If you are trying to move so many records from 

the first record.  Call rs.MoveFirst and then call rs.Move(100).

Though usually, you will see code like this:



Jump = 100

for x = 1 to Jump

rs.movenext

next x



Here is a link to Microsoft that shows the methods you can use:

http://msdn.microsoft.com/library/en-us/adoce31/html/ado30ref_7.asp
Message #3 by "Dallas Martin" <dmartin@z...> on Tue, 28 Aug 2001 19:13:16 -0400
You can specify a "start" parameter to the Move command.



"rs.move 110,1" will move to the 110th record counting from record 1.



If the cursor type is NOT a forward-only cursor, you can also use a negative

value: rs.move -10,110 will move to record number 100.



Ofcourse, don't forget to take into account any "ORDER BY" clause in

your SELECT statement. If you have an ORDER BY clause, all record

positioning is relative to the ordering of your records.



Also, after a move you should check the BOF and EOF conditions before

you attempt to access the field values.



Dallas





----- Original Message -----

From: "Tom Small" <Tom.Small@g...>

To: "ASP Databases" <asp_databases@p...>

Sent: Tuesday, August 28, 2001 10:40 PM

Subject: [asp_databases] Re: Moving to n + records





> > HI all

> >

> > Does anyone know how I can move to through a recordset to certain + # of

> > records IE. If current record is 100 move to record 110.

> > I am not sure how to do this since you can only move 1 forward or back

> > with the rs.MovePrevious and rs.MoveNext I tried to rs.Move (10) but

> this

> > moves the current record; doesn't bring me the record specified.

> >

> > Thanks

>

> rs.Move 100 or rs.Move(100) will move you forward 100 records from that

> current record position.  If you are trying to move so many records from

> the first record.  Call rs.MoveFirst and then call rs.Move(100).

> Though usually, you will see code like this:

>

> Jump = 100

> for x = 1 to Jump

> rs.movenext

> next x

>

> Here is a link to Microsoft that shows the methods you can use:

> http://msdn.microsoft.com/library/en-us/adoce31/html/ado30ref_7.asp

>

Message #4 by "Geoff Higgins" <Geoff@v...> on Wed, 29 Aug 2001 08:43:35 +0100

You could use



    rs.AbsolutePosition = 110



Geoff



> Subject: Moving to n + records

> From: "Yanira" <ycastaneda@d...>

> Date: Tue, 28 Aug 2001 20:23:42

> X-Message-Number: 6

>

> HI all

>

> Does anyone know how I can move to through a recordset to certain + # of

> records IE. If current record is 100 move to record 110.

> I am not sure how to do this since you can only move 1 forward or back

> with the rs.MovePrevious and rs.MoveNext I tried to rs.Move (10) but this

> moves the current record; doesn't bring me the record specified.

>

> Thanks

> ----------------------------------------------------------------------







Message #5 by "Hasenfratz, Philipp" <maillist@e...> on Wed, 29 Aug 2001 15:44:29 +0200
> You can specify a "start" parameter to the Move command.

>

> "rs.move 110,1" will move to the 110th record counting from record 1.

>

> If the cursor type is NOT a forward-only cursor, you can also use a

negative

> value: rs.move -10,110 will move to record number 100.

>

> Ofcourse, don't forget to take into account any "ORDER BY" clause in

> your SELECT statement. If you have an ORDER BY clause, all record

> positioning is relative to the ordering of your records.

>

> Also, after a move you should check the BOF and EOF conditions before

> you attempt to access the field values.



It's also possible to do it with SQL : ( in some cases I dislike changeing

my progs )



instead of



SELECT * FROM table;



you can use



SELECT * FROM table LIMIT 100, 10;



the SQL server will return 10 records starting with record #100.





Philipp



Message #6 by "Tomm Matthis" <matthis@b...> on Wed, 29 Aug 2001 11:09:01 -0400
Philipp,

Where is this documented? I tried this but get an error.....



Is this specific to the RDMS and not ANSI ?



-- Tomm





> It's also possible to do it with SQL : (in some cases I dislike changeing

> my progs) instead of

>

> SELECT * FROM table;

>

> you can use

>

> SELECT * FROM table LIMIT 100, 10;

>

> the SQL server will return 10 records starting with record #100.

>

>

> Philipp
Message #7 by "Hasenfratz, Philipp" <maillist@e...> on Wed, 29 Aug 2001 17:32:10 +0200
> Philipp,

> Where is this documented? I tried this but get an error.....

>

> Is this specific to the RDMS and not ANSI ?

>

> -- Tomm



Hi Tomm,



which DB are you using? - Access, MS SQL Server, mysql, oracle, progres?



the select statement I've wrote is standard SQL 1.0. You should find it in

every SQL documentation.



---Philipp



Message #8 by "Yanira" <ycastaneda@d...> on Wed, 29 Aug 2001 16:24:36
Thanks to All 



I will try your suggestions 



Thanks 



Yanira 



> HI all 

> 

> Does anyone know how I can move to through a recordset to certain + # of 

> records IE. If current record is 100 move to record 110.

> I am not sure how to do this since you can only move 1 forward or back 

> with the rs.MovePrevious and rs.MoveNext I tried to rs.Move (10) but 

this 

> moves the current record; doesn't bring me the record specified.  

> 

> Thanks 

  Return to Index