I have a table which contains two columns: ID and username. I need to create an 1 dimensional array which contains the usernames so that Array(ID) gives the corresponding username. So when I response.write eg. Array(5) it will write the username of the member with the ID 5.
I have done it like this. I use GetRows because I have heard it is a lot faster than using movenexts and stuff like that.
SQL = "SELECT ID, Username FROM MEMBERS"
Set RS = Conn.Execute(SQL)
Dim GetRowsArray
GetRowsArray = RS.GetRows
Dim Array(55)
For rowcounter=0 To UBound(GetRowsArray,2)
ID = GetRowsArray(0,rowcounter)
Username = GetRowsArray(1,rowcounter)
Array(ID) = Username
Next
RS.Close
Set RS = Nothing
This works fine, but my problem is the Dim Array(55) line. I have to enter 55 manually as I know there are 55 members in the database. But I don't know how to dim it dynamically (so that I don't have to enter the number of members manually after each update).
I have tried this but it says something like error: integer expected.
num = UBound(GetRowsArray,2)
Dim Array(num)
Any suggestions?