?
Solved

ASP Run Loop Twice

Posted on 2009-05-05
5
Medium Priority
?
451 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

771 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