Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Loop Statement


Message #1 by "Deepa" <deepa@e...> on Thu, 25 Jan 2001 10:27:40 +0530
This is a multi-part message in MIME format.



------=_NextPart_000_0074_01C086B9.72175F60

Content-Type: text/plain;

	charset="iso-8859-1"

Content-Transfer-Encoding: quoted-printable



Hi All,



Here's my question ..



While fetching records (many rows) from a table & passing it to a 

control box we use either of these



  1. Do while rs.eof

      ......

      rs.movenext

      Loop



  2. Do

      ..

      rs.movenext

      Loop until rs.eof



  3. While rs.eof

      ...

      rs.movenext

      Wend



  Which is the best option & why ?



  Thanx in advance ,

  Deepa.






Message #2 by "Ken Schaefer" <ken@a...> on Thu, 25 Jan 2001 18:46:14 +1100
I don't think there is a "best" way. Microsoft seems to be recommending the

Do While...Loop structure instead:



http://msdn.microsoft.com/scripting/vbscript/download/vbsdoc.exe



Cheers

Ken



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

From: "Deepa" <deepa@e...>

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

Sent: Thursday, January 25, 2001 3:57 PM

Subject: [asp_databases] Loop Statement





Hi All,



Here's my question ..



While fetching records (many rows) from a table & passing it to a control

box we use either of these



  1. Do while rs.eof

      ......

      rs.movenext

      Loop



  2. Do

      ..

      rs.movenext

      Loop until rs.eof



  3. While rs.eof

      ...

      rs.movenext

      Wend



  Which is the best option & why ?



  Thanx in advance ,

  Deepa



Message #3 by Imar Spaanjaars <Imar@S...> on Thu, 25 Jan 2001 08:42:55 +0100
Only the second, in this case, because the first and last won't work.



You state while rs.EOF ..... loop, this basically means: while the 

recordset is empty, go fetch a new record, which is obviously not gong to work.



What I usually see is:



do while not Recordset.EOF

         Recordset.MoveNext()



loop



but I think the other options are used as well.

Not sure about Loop Until, by the way. Is that supported in VBScript??



Imar







At 10:27 AM 1/25/2001 +0530, you wrote:

>Hi All,

>

>Here's my question ..

>

>While fetching records (many rows) from a table & passing it to a control 

>box we use either of these

>

>1. Do while rs.eof

>     ......

>     rs.movenext

>     Loop

>

>2. Do

>     ..

>     rs.movenext

>     Loop until rs.eof

>

>3. While rs.eof

>     ...

>     rs.movenext

>     Wend

>

>Which is the best option & why ?

>

>Thanx in advance ,

>Deepa.



Message #4 by "Ken Schaefer" <ken@a...> on Thu, 25 Jan 2001 19:44:02 +1100

> Not sure about Loop Until, by the way. Is that supported in VBScript??



Supported since VBScript v1 :-)

But good pick up on the fact that the first and third options wont do

anything...I missed that completely!



Cheers

Ken



Message #5 by "Deepa" <deepa@e...> on Thu, 25 Jan 2001 14:17:49 +0530
1 . In the first loop , rs.eof means that rs.eof = false

2. In the 2nd loop , its execute the loop until its eof .



Its working for me . anyway thanx .



Deepa.



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

From: "Ken Schaefer" <ken@a...>

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

Sent: Thursday, January 25, 2001 2:14 PM

Subject: [asp_databases] Re: Loop Statement





>

> > Not sure about Loop Until, by the way. Is that supported in VBScript??

>

> Supported since VBScript v1 :-)

> But good pick up on the fact that the first and third options wont do

> anything...I missed that completely!

>

> Cheers

> Ken





Message #6 by Imar Spaanjaars <Imar@S...> on Thu, 25 Jan 2001 10:16:12 +0100

>Supported since VBScript v1 :-)





Hmmm, I should have looked that up at 

http://msdn.microsoft.com/scripting/vbscript/doc/vbstoc.htm , right?? ;-)



Imar














  Return to Index