how to add csv files in dataset base

B

Bruno

Hi

i try to import a .csv file to my dataset base but when i want used
OleDbDataAdapter, i have error.

my connection string :

"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"DataSource=c:\somepath\csvfile;" & _
"Extended Properties=""text;HDR=Yes;FMT=Delimited"""

Thanks for help
 
P

Paul Clement

¤ Hi
¤
¤ i try to import a .csv file to my dataset base but when i want used
¤ OleDbDataAdapter, i have error.
¤
¤ my connection string :
¤
¤ "Provider=Microsoft.Jet.OLEDB.4.0;" & _
¤ "DataSource=c:\somepath\csvfile;" & _
¤ "Extended Properties=""text;HDR=Yes;FMT=Delimited"""
¤

What is the error? In addition, the Data Source should be the path where your csv file is located -
it should not specify the actual file. That is done in your SQL statement.

Dim TextConnectionString As String
TextConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & "c:\TestData" & ";" & _
"Extended Properties=""Text;HDR=Yes;FMT=Delimited;"""
Dim TextConn As New System.Data.OleDb.OleDbConnection(TextConnectionString)
TextConn.Open()

Dim da As New System.Data.OleDb.OleDbDataAdapter("Select * from test.csv", TextConn)

Dim ds As DataSet = New DataSet("CSVFiles")
da.Fill(ds, "test.csv")

TextConn.Close()


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 

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