Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Microsoft: ASP (Active Server Pages) FAQ

ASP 102

Looping to display all data in a multidimensional array (getRows() or other array) by Abraxus
Posted: 21 Nov 06 (Edited 29 Nov 06)

Multidimensional arrays can be tricky to work with.  One of the most common ways of producing a multidimensional array is by creating a recordset and then dumping the data into an array using the ASP getRows() command.  This is a quick FAQ answer to explain how to work with multidimensional arrays.


' Assuming we have created a connection, executed some SQL,
' and opened a recordset named rs
' Now we can dump all of the data in rs into an array called rsArray

rsArray = rs.getRows()

' An advantage of getRows() - rs object is no longer needed in memory

set rs = nothing

' If the array is a large grid of data, you identify
' the columns as (rsArray, 1) and the rows as (rsArray, 2)
' A single item in the array is located at rsArray(column, row)

colStart = LBound(rsArray, 1)
colEnd   = UBound(rsArray, 1)
rowStart = LBound(rsArray, 2)
rowEnd   = UBound(rsArray, 2)

' Loop through all rows of the array and display the data

Response.Write("<table>" & chr(13))
For row=rowStart to rowEnd
   Response.Write("<tr>" & chr(13))
   ' For each row we loop through every column
   For col=colStart to colEnd
      Response.Write(chr(9) & "<td>" & rsArray(col,row) & "</td>" & chr(13))
   Response.Write("</tr>" & chr(13))
Response.Write("</table>" & chr(13))
The chr commands in the output lines insert tabs and carriage returns to format the source for easy viewing.

If you have any questions about multidimensional arrays or suggestions for expanding this FAQ please drop me a note!

Back to Microsoft: ASP (Active Server Pages) FAQ Index
Back to Microsoft: ASP (Active Server Pages) Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close