VB Code:
Function FetchArray(strQuery As String, conn As ADODB.Connection) As Variant Dim resBuff() As Variant Dim nRS As ADODB.Recordset Dim fld As ADODB.Field Dim iRow As Integer, iField As Integer Set nRS = New ADODB.Recordset nRS.CursorLocation = adUseServer nRS.Open strQuery, conn nRS.MoveFirst iRow = -1 iField = -1 Do Until nRS.EOF iRow = iRow + 1 For Each fld In nRS.Fields iField = iField + 1 [b] resBuff(iRow, iField) = fld.Value[/b] Debug.Print resBuff(iRow, iField) Next Loop End Function
It seems to have trouble on ^ that line.
I tried resBuff(iRow)(iField) = fld.Value but I can't even remember how to do 2d arrays in vb now.
I was hoping to re create some of the PHP->mysql functions in vb because i hate recordsets
The idea of the above is to load a query into an array.
Any ideas?





Reply With Quote