The equivalent would be (in my opinion):
Dim oddr As OleDb.OleDbDataReader
Dim odcmd As OleDb.OleDbCommand
Dim odconn As OleDb.OleDbConnection
odconn = New OleDb.OleDbConnection("connection string")
odcmd = New OleDb.OleDbCommand("command string", odconn)
oddr = odcmd.ExecuteReader
While (oddr.Read)
Dim dataArr(oddr.FieldCount) As String
For i = 0 To oddr.FieldCount - 1
dataArr(i) = oddr.GetValue(i).ToString()
Next
End While
I assume you just wanted to get a translation as the code doesn't keep the
values of dataArr beyond the inside of each loop.
"John" wrote:
Hi
I have below code which is written using a datatable dt. What is the
equivalent code using a OleDbDataReader?
For j = 0 To dt.Rows.Count - 1
Dim dataArr(dt.Columns.Count) As String
For i = 0 To dt.Columns.Count - 1
dataArr(i) = dt.Rows(j)(i)
Next
Next
Thanks
Regards