Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How To read tab delimited file using ADO, Connect to text driver?

305 views
Skip to first unread message

Jessie Niu

unread,
Aug 13, 2004, 1:54:14 AM8/13/04
to
Hi, I can connect to text file driver with coma delimited file, how not Tab
delimited?

if I use the following :
conn.Open "DRIVER={Microsoft Text Driver (*.txt; *.csv)};" & _
"DBQ=" & sFilePath & ";FMT=TabDelimited;", "", ""

it does not work.

Thanks


Jessie


Paul Clement

unread,
Aug 13, 2004, 11:28:13 AM8/13/04
to
On Fri, 13 Aug 2004 15:54:14 +1000, "Jessie Niu" <jes...@asp.com.au> wrote:

¤ Hi, I can connect to text file driver with coma delimited file, how not Tab

Tab delimited files require a schema.ini file which would look something like the following:

[TabDelimitedFile.txt]
ColNameHeader=True
Format=TabDelimited
CharacterSet=ANSI

...and is placed in the same location as the text file.

I would use the Jet OLEDB provider with the Text driver to open the file:

Dim ConnectionString As String

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & "E:\My Documents\TextFiles" & ";" & _
"Extended Properties=""Text;HDR=NO;"""

Dim TextConnection As New System.Data.OleDb.OleDbConnection(ConnectionString)
TextConnection.Open()

Dim da As New System.Data.OleDb.OleDbDataAdapter("SELECT * FROM TabDelimitedFile.txt",
TextConnection)

Dim ds As New DataSet("TextFiles")
da.Fill(ds, "TabDelimited")


Paul ~~~ pcle...@ameritech.net
Microsoft MVP (Visual Basic)

Jessie Niu

unread,
Aug 16, 2004, 7:17:56 PM8/16/04
to
Thanks

Jessie
"Paul Clement" <UseAdddressA...@swspectrum.com> wrote in message
news:g8nph0l4tl1a4mat1...@4ax.com...

0 new messages