Trying to read CSV file into VB.NET 2005

  • Thread starter Thread starter Zim Babwe
  • Start date Start date
Z

Zim Babwe

I have some code and I know the Connection string is wrong, but I don't know
the correct syntax. Can someone help please? I want to read a .CSV file
and input the data into a table. Am I on the right track? Any
help/corrctions would be appreciated. This is VS 2005, Windows Application
using VB.NET.


Dim sConnectionString As String = "Driver={Microsoft Text Driver" & _
"(*.txt; *.csv)};Dbq=C:\Stock
Market\;Extensions=asc,csv,tab,txt;"

Dim objConn As New Odbc.OdbcConnection(sConnectionString)
Dim objCmdSelect As New Odbc.OdbcCommand("SELECT * FROM
AMEX_20070302.csv", objConn)

Dim objAdapter1 As New
Odbc.OdbcDataAdapter(objCmdSelect.CommandText, objConn)
Dim objDataset1 As New DataSet()

objAdapter1.Fill(objDataset1, "Table1")
DataGridView1.DataSource = objDataset1.Tables(0).DefaultView
objConn.Close()
 
dude don't listen to these kids


use BULK INSERT in order to import CSV into a table


ADO.net is bloatware; sorry
 
Back
Top