How to get all the id numbers in database then store all id numbers to array in vb6?
Or is there another way to store all id numbers in one variable only? Because later in the program, I will use the id numbers one by one.
The GetRows method of an ADO recordset returns an array.
This sample opens the table as a recordset and loads its id values into an array.
Dim rs As Object
Dim varGetRows As Variant
Set rs = CreateObject("ADODB.Recordset")
rs.Open "tblFoo", CurrentProject.Connection
varGetRows = rs.GetRows(, , "id")
I don't know what you want to do with the array, so I'll just examine its values ...
Dim lngUBound As Long
Dim i As Long
lngUBound = UBound(varGetRows, 2)
For i = 0 To lngUBound
Debug.Print varGetRows(0, i)
Next i
If you're interested in something other than an array, you could use a Collection or Dictionary.