Customer Login  .   Webmail Login  .   About Us  .   Contact Us
Go to: Articles List

Arrays How To Part 4 : Recordsets in to a multi-dimensional array
[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).

Shared Hosting
Rookie
Pro
Advanced
Dedicated Servers
BASE
BUSINESS
ENTERPRISE
Why Choose Brinkster?
Radical Support
Brinkster Datacenter
Brinkster Network
Corporate Social Responsibility
90 Day Money Back Guarantee
Unsurpassed Value
Client Testimonials
Additional Features
Antivirus
Merchant Account
E-Commerce
Live Chat Communicator
Free Firewall
Website Builder
Free Web Hosting
Support
General Support
Codebank Search
Forums
Articles
Click here for Brinkster Live Chat
Home   Domains   Shared Hosting   Dedicated Hosting   Partner   Support   About Us    Contact Us   Webmail
Copyright © Brinkster Communications Corporation All Rights Reserved. Privacy Policy & Legal