Go to: Articles List
Part 1 | Part 2 | Part 3 | Part 4
Steps:
1. Execute the sql
2. Loop through the recordset
3. ReDim the array with the preserve keyword
4. Put RS in array item by item
sql = "select * from myTable"
Set RS = Conn.Execute(sql)
'Put the recordset in an array
Dim myArray()
numRows = 0
Do While NOT RS.EOF
numRows = numRows + 1
ReDim Preserve myArray(3, numRows)
myArray(0, numRows - 1) = RS(0)
myArray(1, numRows - 1) = RS(1)
myArray(2, numRows - 1) = RS(2)
myArray(3, numRows - 1) = RS(3)
RS.MoveNext
Loop
What you end up with is a 4 dimensional array (4 columns and a dynamic
number of rows, depending on the number of records in the db).
|
|
|
|