I was wondering if someone could help me.
I have to parse data from a csv file and put this into a db table. An example of the data is as follows:
"first field", "second , field", "third " Field " ", "fourth field"
As you can see there are quotation marks and commas embedded in the fields. I was using ADO.NET but it had issues with the embedded quotation marks. Any field after the embedded quotation marks would be null
e.g. from the example above the following would be inserted into the DB table.
first field | second, field | third | NULL
Here is the code i am using.
Dim dataTable As New DataTable
Dim dataAdapter As New OleDbDataAdapter
Dim cmd As New OleDbCommand
Dim path As String = "c:\"
Dim conn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& System.IO.Path.GetDirectoryName(filename) & ";Extended Properties=""Text;HDR=Yes;FMT=Delimited""")
cmd.CommandText = "Select * FROM " & System.IO.Path.GetFileName(filename)
dataAdapter.SelectCommand = cmd
cmd.Connection = conn
conn.Open()
dataAdapter.Fill(dataTable)
Then I insert data into the db table.
Any advice or guidance on this would be greatly appreciated.