Connecting Tech Pros Worldwide Forums | Help | Site Map

Simple Loop Problem

Newbie
 
Join Date: Apr 2007
Posts: 3
#1: Apr 9 '07
Hi everyone,

I am relativly new to asp and am having a problem with a loop.

This is my select statement:

Expand|Select|Wrap|Line Numbers
  1. strSql = "SELECT newsletters.*, homePage.*, pointsTable.*, pointsTable.for-pointsTable.against as gd FROM newsletters, homePage, pointsTable ORDER BY pointsTable.points DESC, pointsTable.for-pointsTable.against DESC;"
This works perfectly when the loop code is taken out, but when it is in it creates the following error:

Expand|Select|Wrap|Line Numbers
  1. ADODB.Field error '80020009' 
  2.  
  3. Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record. 
  4.  
  5. /index.asp, line 0 
I understand that it is trying to tell me there is no records in that field, but what I can't ubderstand is that if the loop is not there it works and if it is there it doesen't, frustrating!

Below is the looping code:

Expand|Select|Wrap|Line Numbers
  1. <%if NOT rscuafc.eof then
  2.   do until rscuafc.eof%>
  3.                         <tr>
  4.                           <td bgcolor="#E6E6FF"><img src="images/spacer.gif" width="1" height="2"></td>
  5. .
  6. .
  7. .
  8. .
  9. <td bgcolor="#CCCCCC"><img src="images/spacer.gif" width="1" height="1"></td>
  10. </tr>
  11. <%rscuafc.MoveNext
  12. Loop
  13. Else
  14. response.write "Sorry, there are no records."
  15. End If%>
any help would be greatly appreciated!

Thanks in advance.

jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#2: Apr 10 '07

re: Simple Loop Problem


Doesn't "do until" execute once after the condition is reached? That could cause the problem. Try "do while NOT rscuafc.eof" instead.

Let me know if this helps.

Jared
iam_clint's Avatar
Forum Leader
 
Join Date: Jul 2006
Location: Oklahoma
Posts: 1,076
#3: Apr 10 '07

re: Simple Loop Problem


or while not, i don't like do's


while not rsname.eof

rsname.movenext
wend
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#4: Apr 11 '07

re: Simple Loop Problem


Quote:

Originally Posted by iam_clint

or while not, i don't like do's


while not rsname.eof

rsname.movenext
wend

Hey Clint, could you clarify something for me? I was under the mpression that do while ... loop was the same as while ... wend. Is there a technical difference, or is it just a matter of preference?

Jared
iam_clint's Avatar
Forum Leader
 
Join Date: Jul 2006
Location: Oklahoma
Posts: 1,076
#5: Apr 11 '07

re: Simple Loop Problem


preference really there are some differences i can't think of off the top of my head.
Reply