skibascott
IS-IT--Management
I am trying to read a recordset into a multidimensional array. Here is the code that I have so far:
For each record I only want to read the three fields: sheetno, pattern and machine. What I am aiming for is this example: avarFields(0,0)=8596 (which is the sheetno)
avarFields(0,1)=RF2L005 (this is the pattern)
avarFields(0,2)=Mold/Pour (this is the machine)
I have been able to succesfully copy this data into a one-dimension array, so the db connection details that are not shown are correct. When executing the code here, I receive a subscript out of range error that cites the ReDim line. There are most likely a few problems here, for I am totally new to ASP. Any suggestions on where to start?
Code:
<%
Dim objRS
Dim numRows
Dim avarFields(2)
avarFields(0,) = "sheetno"
avarFields(1) = "pattern"
avarFields(2) = "machine"
Set objRS = Server.CreateObject ("ADODB.Recordset")
objRS.Open "GrindsheetLR",strConnect,adOpenKeyset,adLockReadOnly, adCmdTable
numRows = 0
Do While NOT objRS.EOF
numRows = numRows + 1
ReDim Preserve avarFields(2, numRows)
avarFields(0, numRows - 1) = objRS(0)
avarFields(1, numRows - 1) = objRS(1)
avarFields(2, numRows - 1) = objRS(2)
objRS.MoveNext
Loop
objRS.Close
Set objRS = Nothing
%>
For each record I only want to read the three fields: sheetno, pattern and machine. What I am aiming for is this example: avarFields(0,0)=8596 (which is the sheetno)
avarFields(0,1)=RF2L005 (this is the pattern)
avarFields(0,2)=Mold/Pour (this is the machine)
I have been able to succesfully copy this data into a one-dimension array, so the db connection details that are not shown are correct. When executing the code here, I receive a subscript out of range error that cites the ReDim line. There are most likely a few problems here, for I am totally new to ASP. Any suggestions on where to start?