468,510 Members | 1,687 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,510 developers. It's quick & easy.

classic asp rs loop from sql database on selected rows possible?

120 100+
hi guys

i can perform an asp rs loop from a sql db fine - my question is how do I only loop through a selection of records? for example 1-5? or 6-10?

below is my code;
Expand|Select|Wrap|Line Numbers
  1. If objRS35and36.Eof Then 
  2. Response.write "<div align='center'>Sorry there are no current records.</div>" 
  3. Else 
  4.  
  5. Response.Write "<table align=""center"" id=""flightspecialscontainer"" cellpadding=""0"" cellspacing=""0"">"
  6. Response.Write "<tr><td>"
  7.  
  8. Do while not objRS35and36.Eof 
  9. Response.Write "<table align=""center"" cellpadding=""0"" cellspacing=""0"" id=""flightspecialroutetable"">"
  10. Response.Write "<tr><td>" & objRS35and36("Anchor_Tag") & vbCrLf & "<fieldset class=""fieldsetspecialpricebox"">" & vbCrLf
  11. Response.Write "<legend>" & vbCrLf & "<span class=""specialtitlesmall"">" & objRS35and36("Flight_Route") & "</span>" & vbCrLf & "</legend>" & vbCrLf
  12. Response.Write "<table align=center cellpadding=0 cellspacing=0 class=""specialpricetable"">" 
  13.  
  14. Response.Write "<tr>" & vbCrLf & "<td class=""pricetd"">&pound;" & objRS35and36("Price_Band_1") & "</td>" & vbCrLf
  15. Response.Write "<td class=""datetd""><span class=""monthspan"">" & objRS35and36("Month_Band_1") & "&nbsp;</span>" & objRS35and36("Date_Band_1") & "</td>" & vbCrLf & "</tr>" & vbCrLf
  16. Response.Write "<tr>" & vbCrLf & "<td class=""pricetd"">&pound;" & objRS35and36("Price_Band_2") & "</td>" & vbCrLf
  17. Response.Write "<td class=""datetd""><span class=""monthspan"">" & objRS35and36("Month_Band_2") & "&nbsp;</span>" & objRS35and36("Date_Band_2") & "</td>" & vbCrLf & "</tr>" & vbCrLf
  18. 'end table setup
  19. Response.Write "<td colspan=""2"" class=""specialbookbuttontd""><a class=""button"" href=""#BackToTop"" onClick=""change_booking(" & objRS35and36("Book_Button") & ")"">BOOK NOW !</a></td>"
  20. Response.Write "</tr>" & vbCrLf & "</table>" & vbCrLf & "</fieldset>"  & vbCrLf
  21. Response.Write "</td></tr></table>" & vbCrLf & vbCrLf
  22.  
  23. 'move to the next record in the recordset
  24. objRS35and36.movenext
  25.  
  26. Loop 
  27. end if 
  28.  
thanks in advance
omar
Apr 17 '10 #1
2 4066
omar999
120 100+
oh my God what a newbie question im posting first thing in the morning. I've had a little think about this and I've worked it out.

All I've done is modified my sql statement to select certain rows by their ID - so something like select * from column name where ID in (1, 2, 3) etc etc

then the loop only loops through these 3 rows! problem solved. :)
Apr 17 '10 #2
jhardman
3,405 Expert 2GB
I was going to suggest changing your "do until rs.eof" to "for x = 0 to 4"
Expand|Select|Wrap|Line Numbers
  1. for x = 0 to 4
  2.    '...
  3.    rs.movenext
  4.    if rs.eof then exit for
  5. next
but I'm glad you found a solution.

Jared
Apr 19 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by Wayne Smith | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.