Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Read Tab Delimited text into dataset

Posted on 2007-11-26
1
Medium Priority
?
3,354 Views
Last Modified: 2013-11-07
I have a tab delimited text file that I need to read into a dataset.  I have tried using Microsoft Jet OLEDB4.0 approach, which I can't seem to get to work and I also tried using a TextFieldParser, which almost worked, I was able to read a single row in.   An example of reading in tab delimited text into a dataset (datatable, whatever) using VB.net 2.0 would be greatly appreciated.  I have found a ton of examples on the web, however (at least so far) none of them have worked.

thanks,
0
Comment
Question by:clintnash
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 16

Accepted Solution

by:
gnoon earned 2000 total points
ID: 20356411
1. Create a folder to contains data files e.g. c:\data
2. Copy the tab delimited file(s) into the folder e.g. data.tab
    The file must contains only data, and no column names at the first line.
3. Create a file named schema.ini in the folder, and contains this information
      [data.tab]
      Format=TabDelimited
4. Write a program to read the file data.tab
Dim myConnection As New System.Data.OleDb.OleDbConnection( _
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\data;" & _
    "Extended Properties='text;FMT=TabDelimited;HDR=YES;'")
Dim myCommand As New System.Data.OleDb.OleDbCommand( _
    "SELECT * FROM data.tab", myConnection)
Dim sd As DataSet = New DataSet
Try
    myConnection.Open()
    Dim query As System.Data.OleDb.OleDbDataAdapter = _
	New System.Data.OleDb.OleDbDataAdapter(myCommand)
    query.Fill(sd)
    For Each r As DataRow In sd.Tables(0).Rows
	For Each o As Object In r.ItemArray
	    Console.Write(o & " ")
	Next
	Console.WriteLine()
    Next
Finally
    myConnection.Close()
End Try

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question