PDA

Click to See Complete Forum and Search --> : My Loop


7up
Mar 12th, 2001, 11:55 AM
Hi guys,
I have a loop to write out the contents of my query.

<%
do while NOT oRSv.EOF
Response.Write "<option value='" & oRSv("Date") & "'>"
Response.Write oRSv("Date") & "</option>&nbsp&nbsp&nbsp"
Response.Write "<option value='" & oRSv("Step") & "'>"
Response.Write oRSv("Step") & "</option><br>"

oRSv.MoveNext


Loop
oRSv.Close
Set oRSv=nothing

%>


its in an asp page but its writting out my data 5 times instead of once. because the number of frecords differ everytime I have no way of stopping this.

Any Ideas?

compuGEEK
Mar 12th, 2001, 12:08 PM
Try this:



Do Until oRSv.EOF
Response.Write "<option value='" & oRSv("Date") & "'>"
Response.Write oRSv("Date") & "</option> "
Response.Write "<option value='" & oRSv("Step") & "'>"
Response.Write oRSv("Step") & "</option><br>"
oRSv.MoveNext
Loop

7up
Mar 12th, 2001, 12:27 PM
nope it didnt work

thanks anyway

:(

Imanta
Mar 21st, 2001, 02:21 PM
You know I read your post and the others and I am not sure what it is you want to do with the code?

Your code is setup to do a query and then loop through all the results (5, 10, however many) and print them out. If you have 10,000 records and there is no restrictions in your query it will continue to run.

So what is it you want to see?

nybble
Mar 21st, 2001, 04:35 PM
yea... u need to show us your querystring

also don't forget about Exit Do.

7up
Mar 22nd, 2001, 05:26 AM
I was only new to sql server 7 and i imported the data too many times, silly me