cdemott33
asked on
Looping through a multidimensional array - Classic ASP/VB Script
The title pretty much says it all. I created my array as follows:
Then I wrote the following to loop through the array but it's not working:
When I load the page it only loads 6 records and stops. There are about 30 records the page should be displaying.
I have a feeling that this line here is wrong...
... but I'm not sure how to fix it. Can someone please help me?
' Multidimensional Array
' arrTransactions(col,row)
ReDim arrTransactions(6,0)
' SQL Statement
strSQLStatement = "SELECT transactionNumber, jobNumber, eventName, collateralID, arrivalDate, returnDate, quantity " & _
"FROM collateralOut " & _
"WHERE collateralID ='" & strCollateralID & "' " & _
"ORDER BY arrivalDate DESC"
' Connection
Set conn = Server.CreateObject("ADODB.Connection")
conn.open connectionStr
' Create our recordset
set strFilename=Server.CreateObject("ADODB.recordset")
strFilename.Open strSQLStatement, conn
If Not strFilename.EOF Then
strFilename.MoveFirst
noRecord = "False"
i = 0
While Not strFilename.EOF
arrTransactions(0,i) = strFilename.Fields("transactionNumber").Value
arrTransactions(1,i) = strFilename.Fields("jobNumber").Value
arrTransactions(2,i) = strFilename.Fields("eventName").Value
arrTransactions(3,i) = strFilename.Fields("collateralID").Value
arrTransactions(4,i) = strFilename.Fields("arrivalDate").Value
arrTransactions(5,i) = strFilename.Fields("returnDate").Value
arrTransactions(6,i) = strFilename.Fields("quantity").Value
' Counter
i = i + 1
' Preserve array position
ReDim Preserve arrTransactions(6,i)
' Move to the next record
strFilename.MoveNext
Wend
Else
noRecord = "True"
End If
' Close our connection
strFilename.Close
Set strFilename = Nothing
Then I wrote the following to loop through the array but it's not working:
<table border="1" cellpadding="5" cellspacing="1" width="80%">
<tr>
<td bgcolor="#eeeff0"><strong>Trans#</strong></td>
<td bgcolor="#eeeff0"><strong>Event Name</strong></td>
<td bgcolor="#eeeff0"><strong>Event Start</strong></td>
<td bgcolor="#eeeff0"><strong>Qty Ordered</strong></td>
<tr>
<%
If NoRecord = "False" Then
For i=0 to (UBOUND(arrTransactions) - 1)
%>
<tr>
<td valign="top"><%= arrTransactions(0,i) %></td>
<td><%= HTMLDecode(arrTransactions(2,i) ) %></td>
<td valign="top"><%= arrTransactions(4,i) %></td>
<td valign="top" align="center"><%= arrTransactions(6,i) %></td>
</tr>
<%
Next
Else
%>
<tr>
<td colspan="5"><strong>No Records Found</strong></td>
</tr>
<%
End If
%>
</table>
When I load the page it only loads 6 records and stops. There are about 30 records the page should be displaying.
I have a feeling that this line here is wrong...
For i=0 to (UBOUND(arrTransactions) - 1)
... but I'm not sure how to fix it. Can someone please help me?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER