By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,677 Members | 1,177 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,677 IT Pros & Developers. It's quick & easy.

Reading CSV file

P: 1
Hi,

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
  1. 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"
  2. Dim conn As Odbc.OdbcConnection = New Odbc.OdbcConnection(sExcelConnectionString)
  3. conn.Open()
  4.             Dim da As Odbc.OdbcDataAdapter = New Odbc.OdbcDataAdapter("SELECT * FROM WebData.csv", conn)
  5.             Dim ds As DataSet = New DataSet()
  6.             da.Fill(ds, "WebData")
  7. For Each dr As Data.DataRow In ds.Tables("WebData").Rows
  8.                 MsgBox(dr(0).ToString)
  9. Next
Jul 27 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.