Solved

ASP Run Loop Twice

Posted on 2009-05-05
5
449 Views
Last Modified: 2012-05-06
I want to run a loop twice. I know it would be more elegant to do all action in one loop but I'm struggling with the syntax and I need the same record set further down the code.  Is the first loop stopping the second?
While  (NOT rsAgents.EOF) 
'Do Action	
rsAgents.MoveNext()
Wend
 
While  (NOT rsAgents.EOF) 
'Do another Action	
rsAgents.MoveNext()
Wend

Open in new window

0
Comment
Question by:webdork
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
Pearl_export_ben earned 500 total points
ID: 24307152
Hope This Helps :)

If you are struggling with code, feel free to open a question with more code and I'll happily debug and explain it to you in more detail
'Scenario 1:
While  (NOT rsAgents.EOF) 
'Do Action      
rsAgents.MoveNext()
Wend
 
'This will take you back up to the top line of your code
rsAgents.MoveFirst()
 
While  (NOT rsAgents.EOF) 
'Do another Action      
rsAgents.MoveNext()
Wend
 
 
'Scenario 2:
While NOT rsAgents.EOF
   Do Action 1
   Do Action 2
   rsAgents.MoveNext
Wend

Open in new window

0
 
LVL 8

Expert Comment

by:Pearl_export_ben
ID: 24307162
And just to add a little more - Yes the first loop was stopping the second.  The first loop would loop through all your results to EOF (End Of File or ResultSet) and then the second loop would pick up where the first left off - at the end of your data - and thus wouldn't be able to manipulate the already played with data.

Ben
0
 
LVL 8

Expert Comment

by:Pearl_export_ben
ID: 24307201
Triple post - I know its naughty - sorry :(

'This will take you back up to the top line of your code
SHOULD BE
'This will take you to the first result in your file/resultset - not the first line of your code.

Ben
0
 

Author Comment

by:webdork
ID: 24307386
Too easy!
rsAgents.MoveFirst() did the trick.
Thanks.
0
 

Author Closing Comment

by:webdork
ID: 31578123
Oh Goody
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Designing forms 3 70
My Do While is Not Producing Anything 15 86
ASP sending two datas 2 28
Save data in two Database, Asp 2 68
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question