I do have another snippet that I didn't post on here, I started using it after wild_bill made the comment about the OleDb provider. This is it:
Code:Private Function CSV_to_DataTable(ByVal path As String) As DataTable 'Create a new datatable Dim dt As DataTable = New DataTable 'Create a new data connection using the JET engine Dim con As OleDb.OleDbConnection = New OleDb.OleDbConnection(String.Format("Provider={0};Data Source={1};Extended Properties=""Text;HDR=YES;FMT=Delimited""", "Microsoft.Jet.OLEDB.4.0", "C:\")) 'Use the command to select all the records Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand("SELECT * FROM " & path, con) 'Set up a dataadapter Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter 'Open the connection con.Open() 'Set the select command and fill da.SelectCommand = cmd da.Fill(dt) 'Close the connection con.Close() Return dt End Function




Reply With Quote