Continually Improving.... let us know how support@devdiamond.net Sign in | Sign up
home articles news blog forum  

 
 


 
Skip Navigation LinksHome > Article > Arrays :: Recoredsets into a multi-dimensional arrays
Arrays :: Recoredsets into a multi-dimensional arrays
Abstract :
See this example of making your recordset into a Multi-dimensional array, its easer that you might think it is

Views : 10792
Published : Monday, January 21, 2002
By
HyperLink

Avarage Rating :
Page Page 1 of 1

How to put recordset values into an array, first
1. Execute the sql
then 2. Loop through the recordset
inside the loop 3. ReDim the array with the preserve keyword
at last 4. Put RS in array item by item

Here is a code example:

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).



About Author

        Yasir Send Feedback
        Yasir is a .NET expert, with over 5 years experience in Microsoft Technologies, 8 years overall programming experience, he is the owner, founder & primary contributor of Minwar.com, and he also works as IT Director in the hospitality industry.