I've obtained a DataTable which contains the data from a csv file, and I can see that it's populated from its Count property. But I'm unable to get at/display the data in, for example, the Console. I can see it's there (by debugging and spotting it in an ItemList), but I've been going around in circles for ages now
1) How can I display data from any particular row and/or column? I've been trying to bung it into some sort of array, but this isn't working (as yet).
2) How can I next transfer all the data into an array? And can I do this in one go?
Hoping someone can push me in the right direction
Code: Select all
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:" _
& "\Users\Andrew\Documents\;Extended Properties='text;HDR=Yes;FMT=Delimited'"
Dim objConn As New System.Data.OleDb.OleDbConnection(strConn)
objConn.Open()
Dim dt As New DataTable()
Dim cmd As New OleDb.OleDbCommand("SELECT * FROM Employees.csv", objConn)
Dim dba As New OleDb.OleDbDataAdapter
dba.SelectCommand = cmd
dba.Fill(dt)
Dim arrData As New ArrayList(dt.Rows.Count)
For Each aRow As DataRow In dt.Rows
arrData.Add(aRow)
Next
'Dim arr = arrData.ToArray() ??
For Each item In arrData
Console.Write(CType(item, DataRow).ToString) 'no workee
Next 'item
objConn.Close()