Print Page | Close Window

apply loop to one recordset element only

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=4215
Printed Date: 30 March 2026 at 6:38am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: apply loop to one recordset element only
Posted By: the boss
Subject: apply loop to one recordset element only
Date Posted: 12 July 2003 at 7:14pm


i've a page which displays results from a recordset..

sample code below

  <td nowrap>CC</td>
    <td nowrap><%=rs("CC")%></td>
  </tr>
  <tr>
    <td nowrap>FF</td>
    <td nowrap><%=rs("FF")%></td>
  </tr>
  <tr>

how can i apply loops to <%=rs("CC")%> only..im get an EOF or BOF error when i apply loop to only on elemnt in recordset..what is a work around to this...



-------------
http://www.web2messenger.com/theboss">



Replies:
Posted By: ljamal
Date Posted: 12 July 2003 at 7:27pm
Set the record to an array
arrayName = RecordSetName.GetRows
and you can loop without worrying about EOF or BOF.
The array is a 2 dimensional array. The first dimension is the numerical position of the field starting with 0. The secod dimension is the row number from the recordset (starting with 0).

If you used the following SQL statement:
select field1, field2 from table
and placed it into the array, arrArray then the first to return field1 from the first row would be <%=arrArray(0,0)%>
field2 from the first row is: <%=arrArray(1,0)%>
field2 from the 30th row is: <%=arrArray(0,29)%>

To loop through the array use:
<%
for i = 0 to Ubound(arrArray,2)
' Write the first field for each row i
   Response.write arrArray(0,i) &"<br>"
next
%>



-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net