Trying to read CSV file into VB.NET 2005

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()
 
P

PFC Sadr

dude don't listen to these kids


use BULK INSERT in order to import CSV into a table


ADO.net is bloatware; sorry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top