Using OleDbConnection to Read Tab-Separated File

My tab-delimited file is something like this:

ISO ISO3    ISO-Numeric
AD  AND 20

I've been trying the following code with no luck.

OleDbConnection cn = new  OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= |DataDirectory|;Extended Properties='text;HDR=Yes;FMT=TabDelimited'");
OleDbCommand cmd = new OleDbCommand(@"SELECT * FROM countryInfo.txt", cn);
OleDbDataAdapter da = new OleDbDataAdapter(cmd);

cn.Open();

DataTable dt = new DataTable();
da.Fill(dt);

Here's a screenshot of the Dataset Visualizer. Its obviously not the output i'm after. alt text

Any suggestions? Here's my Schema.ini file. Its in the same directory as the text file.

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

Should i just use something like FileHelpers instead?


@Hans Passant Here's a screenshot. alt text

5
задан Benjamin 20 September 2014 в 00:04
поделиться