The GetRows method of the Recordset object lets you retrieve the resultset and place into a two-dimensional array. The code below then loops through that 2 dimensional array 'ArrResults' and displays the records.
The standard way to retrieve and display records has been to create a recordset object and loop through the records, though with the GetRows method there is only one call to the database making for more efficient code.
We use the UBound function which returns the index of the highest element in the array for both dimensions, this basically lets us know how many times to loop through both the rows and columns.
<%
Dim oConnection, oRecordset
Dim sConnString, sSQL
Dim arrResults
Dim iRowNumber, iColumnNumber
Dim RowCounter, ColumnCounter
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("Users.mdb")
Set oConnection = Server.CreateObject("ADODB.Connection")
oConnection.Open(sConnString)
sSQL = "SELECT * FROM users_tbl"
Set oRecordSet = oConnection.Execute(sSQL)
If Not oRecordSet.EOF Then
arrResults = oRecordSet.GetRows()
oRecordset.Close
Set oRecordSet = Nothing
oConnection.Close
Set oConnection = Nothing
iRowNumber = ubound(arrResults,2)
iColumnNumber = ubound(arrResults,1)
For RowCounter=0 to iRowNumber
For ColumnCounter= 0 to iColumnNumber
Response.Write(arrResults(ColumnCounter,RowCounter)) & " "
Next
Response.write("<br />")
Next
Else
Response.write("There are no records.")
End If
%>