My csv file has rows like this:
"col1","col2"," col3","col4","c ol5"
"04/04/2005 01:05:07.576"," 0","0","0"," 0"
And I am using this code to read the file:
Dim Conn As OdbcConnection
Dim dt As New DataTable
Dim da As OdbcDataAdapter
Dim strConnstr, strImportfolder , strFilename As String
strImportfolder = "D:\"
strFilename = "filename.c sv"
'this is the csv file to be imported
strConnstr = "Driver={Micros oft Text Driver (*.txt; *.csv)};Dbq=" &
strImportfolder & "\;"
Conn = New Odbc.OdbcConnec tion(strConnstr )
da = New Odbc.OdbcDataAd apter("select * from [" + strFilename + "]", Conn)
da.Fill(dt)
MsgBox(dt.Rows( 0).Item(0).ToSt ring)
Console.WriteLi ne(dt.Columns(0 ).ToString)
Console.WriteLi ne(dt.Rows.Coun t)
Dim colnm As DataColumn
For Each colnm In dt.Columns
Console.Write(c olnm.ColumnName )
Next
Strange enough I only see 1 colomnname
When I change the comma's to semicolumns I see all the column name's....
How can I get this to work with the comma's instead of first need to change
the file..
Thanx
"col1","col2"," col3","col4","c ol5"
"04/04/2005 01:05:07.576"," 0","0","0"," 0"
And I am using this code to read the file:
Dim Conn As OdbcConnection
Dim dt As New DataTable
Dim da As OdbcDataAdapter
Dim strConnstr, strImportfolder , strFilename As String
strImportfolder = "D:\"
strFilename = "filename.c sv"
'this is the csv file to be imported
strConnstr = "Driver={Micros oft Text Driver (*.txt; *.csv)};Dbq=" &
strImportfolder & "\;"
Conn = New Odbc.OdbcConnec tion(strConnstr )
da = New Odbc.OdbcDataAd apter("select * from [" + strFilename + "]", Conn)
da.Fill(dt)
MsgBox(dt.Rows( 0).Item(0).ToSt ring)
Console.WriteLi ne(dt.Columns(0 ).ToString)
Console.WriteLi ne(dt.Rows.Coun t)
Dim colnm As DataColumn
For Each colnm In dt.Columns
Console.Write(c olnm.ColumnName )
Next
Strange enough I only see 1 colomnname
When I change the comma's to semicolumns I see all the column name's....
How can I get this to work with the comma's instead of first need to change
the file..
Thanx