Well I found a cool piece of code to import CSV files via oleDB in .net.
The code I found was ok, it was in c#, however I translated to vb.net (cause that is what I am currently using).
Here is the code:
'You must provide the dataTable you want to fill, and the Fully qualified filename (path & filename).
Public Shared Function FillDataTableFromText(ByRef dt As DataTable, ByVal file As String)
dt =
New DataTable
Dim conn As OleDbConnection
Dim sql As String
Dim FileConnection As String
Dim oda As New OleDbDataAdapter
Dim msg As String
FileConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
FileConnection += Path.GetDirectoryName(file) & ";Extended Properties=""Text;HDR=YES;"""
Try
Try
conn =
New OleDbConnection
conn.ConnectionString = FileConnection
conn.Open()
Catch ex As Exception
msg = ex.Message
End Try
sql =
String.Format("SELECT * FROM {0}", Path.GetFileName(file))
oda =
New OleDbDataAdapter(sql, conn)
oda.SelectCommand.ExecuteNonQuery()
oda.Fill(dt)
Catch ex As Exception
End Try
oda.Dispose()
conn.Dispose()
End Function