Currently I have a class that I created that will allow a user to input SQL code and then the class returns the results to an array in which they can further use. Most methods use a loop to transfer the data from the OleDbDataReader object to an array. This can be very slow when dealing with a large number of items.
Current method:
Dim SQLdr As OleDbDataReader 'SQL reader
Dim SQLCmd As New OleDbCommand() 'The SQL Command
Dim firstline As Boolean
SQLCmd.Connection = SQLConn 'Sets the Connection to use with the SQL Command
SQLCmd.CommandText = SQLStr 'Sets the SQL String
SQLdr = SQLCmd.ExecuteReader 'Gets Data
And then later..
While (SQLdr.Read)
If firstline = True Then
'fill headers
Do Until j = SQLdr.FieldCount
result(j, i) = SQLdr.GetName(j)
j = j + 1
Loop
firstline = False
j = 0
i = 1
End If
j = 0
Do Until j = SQLdr.FieldCount
ReDim Preserve result(result.GetUpperBound(0), result.GetUpperBound(1) + 1)
If display = True Then
MsgBox(j & ":" & i & SQLdr(j).ToString)
End If
result(j, i) = SQLdr(j).ToString
j = j + 1
Loop
i = i + 1
End While
I want to know if there is a more direct way out there to output the results into an array.. I am sorry but I do not have any idea where to start for this, if it is even possible, or if anyone has tried this before.