I have a little problem reading a csv file. The following is the code that I have and it works, however, it doesn't read the first value in the csv file. In the csv file, I have:
1, test10, test11, test12
2, test20, test21, test22
3, test30, test31, test32
However, then I display the value in the dataset, I get:
2, test20, test21, test22
3, test30, test31, test32
Any idea what the problem is?? Please help
Expand|Select|Wrap|Line Numbers
- Dim sExcelConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Driver={Microsoft Text Driver (*.txt; *.csv)};DBQ=C:\data\websites\WetscoDataDump\R2;Extensions=asc,csv,tab,txt;HDR=YES;Persist Security Info=False"
- Dim conn As Odbc.OdbcConnection = New Odbc.OdbcConnection(sExcelConnectionString)
- conn.Open()
- Dim da As Odbc.OdbcDataAdapter = New Odbc.OdbcDataAdapter("SELECT * FROM WebData.csv", conn)
- Dim ds As DataSet = New DataSet()
- da.Fill(ds, "WebData")
- For Each dr As Data.DataRow In ds.Tables("WebData").Rows
- MsgBox(dr(0).ToString)
- Next