Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to copy data from recordset to an array

Status
Not open for further replies.

xq

Programmer
Jun 26, 2002
106
NL
just want to copy recordset to an multi-dimension array.
thanks a lot!
 
what's wrong with that? it doesnt' work

i = 0
r = rs.RecordCount
f = rs.Fields.Count
ReDim arr(r, f)

Do While Not rs.EOF
On Error Resume Next
For j = 0 To f - 1
arr(i, j) = rs.Fields(j).Value
Next j
On Error GoTo 0
rs.MoveNext
i = i + 1
Loop
 
The problem is the the record/fields .count don't work.

You must add following code:

rs.MoveLast
rs.MoveFirst

and then:

r = rs.RecordCount
f = rs.Fields.Count

.....

Hope this will help you,

ThinLizzy
 
ALternatively, try looking at the GetRows method.

e.g.

Dim arr As Variant ' needs to be a variant
arr=rs.GetRows ' in ADO that's all you need to do!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top