how to add csv files in dataset base

  • Thread starter Thread starter Bruno
  • Start date Start date
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
 
¤ 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)
 
Back
Top