By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,515 Members | 1,042 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,515 IT Pros & Developers. It's quick & easy.

Text files

P: n/a
I have a | (pipe) delimited file that i need to import in to a Dataset. With
code below i get 7 items in the first column of each row and the rest is
empty. PLEASE HELP

Below if the code that does it.

For it to work i needed an ini file with columns defined and at the top of
the ini these options are set

[c125788_1_fi_011404_001.txt]
ColNameHeader=False
Format=CSVDelimited
MaxScanRows=25
CharacterSet=ANSI
<-----------------VB Code------
Dim FilePath As String = "C:\ftproot\TOG\"

Dim Conn As New
System.Data.OleDb.OleDbConnection("Provider=Micros oft.Jet.OLEDB.4.0;Data
Source=" & FilePath & ";Extended Properties=""text;HDR=NO;FMT=Delimited""")

Dim Comm As New System.Data.OleDb.OleDbDataAdapter("select * from
c125788_1_fi_011404_001.txt", Conn)

Dim DS As New DataSet

Try

Comm.Fill(DS)

Catch e As Exception

End Try

Conn.Close()

Dim i As Integer = DS.Tables(0).Rows.Count

End Sub
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"Ruslan Shlain" <rs*****@hotmail.com> wrote in message
news:O8**************@TK2MSFTNGP10.phx.gbl...
I have a | (pipe) delimited file that i need to import in to a Dataset. With code below i get 7 items in the first column of each row and the rest is
empty. PLEASE HELP

Below if the code that does it.

For it to work i needed an ini file with columns defined and at the top of
the ini these options are set

[c125788_1_fi_011404_001.txt]
ColNameHeader=False
Format=CSVDelimited
MaxScanRows=25
CharacterSet=ANSI
<-----------------VB Code------
Dim FilePath As String = "C:\ftproot\TOG\"

Dim Conn As New
System.Data.OleDb.OleDbConnection("Provider=Micros oft.Jet.OLEDB.4.0;Data
Source=" & FilePath & ";Extended Properties=""text;HDR=NO;FMT=Delimited""")
Dim Comm As New System.Data.OleDb.OleDbDataAdapter("select * from
c125788_1_fi_011404_001.txt", Conn)

Dim DS As New DataSet

Try

Comm.Fill(DS)

Catch e As Exception

End Try

Conn.Close()

Dim i As Integer = DS.Tables(0).Rows.Count

End Sub

Off the hip....
Forget the Connection and DataAdapter. Create a DataTable, then, using a
rows and column object, add you're rows. To step backward, make a string(),
read each line in and use a Split function to seperate those suckers out,
then add them to the table, adding the table to the DataSet. That would be
my solution.

HTH
Sueffel
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.558 / Virus Database: 350 - Release Date: 1/2/2004
Nov 20 '05 #2

P: n/a
On Wed, 14 Jan 2004 15:44:20 -0600, "Ruslan Shlain" <rs*****@hotmail.com> wrote:

I have a | (pipe) delimited file that i need to import in to a Dataset. With
code below i get 7 items in the first column of each row and the rest is
empty. PLEASE HELP

Below if the code that does it.

For it to work i needed an ini file with columns defined and at the top of
the ini these options are set

[c125788_1_fi_011404_001.txt]
ColNameHeader=False
Format=CSVDelimited
MaxScanRows=25
CharacterSet=ANSI


You might want to post the first ten or twenty lines of your text file if possible.

BTW, if the delimiter is a pipe character then you will need to change the Format argument in your
schema.ini file to:

Format=Delimited(|)
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.