import

V

Viswanathan S

Hi All!

How to import text file into vb.net dataset?

For example a text file with 1000 records as tab delimited text. The text
file contain string, number and date field data. I want to extract the data
between two dates from the text file and bind to the dataset.

How can i do this?

TIA
______________________________

S. Viswanathan
 
P

Paul Clement

¤ Hi All!
¤
¤ How to import text file into vb.net dataset?
¤
¤ For example a text file with 1000 records as tab delimited text. The text
¤ file contain string, number and date field data. I want to extract the data
¤ between two dates from the text file and bind to the dataset.
¤
¤ How can i do this?

Tab delimited text files require a schema.ini file. It would look something like the following and
is located in the same folder as the text file(s).

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

Code:

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
~~~~
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