Connection string for text files

  • Thread starter Thread starter TF
  • Start date Start date
T

TF

hi,

Can anyone please tell me the ADO.NET connection string to access data
from flat files (CSV or other character delimited). I tried it with
OLE DB provider for ODBC (MSDASQL) but got error that it is not
supported in .NET.

Thanks in advance

TF
 
Hi,

This one was suggested by Paul Clement a month ago or so:
Use the Jet OLEDB driver with the Text ISAM instead:

Dim TextConnectionString As String
TextConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & "c:\TestData" & ";" & _
"Extended Properties=""Text;HDR=NO;"""
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")
 
Back
Top