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.
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.
Well, one obvious candidate is that this white space isn't actually a tab but spaces. Try FMT=Delimited( ). Use a hex viewer to see what's really there. Backgrounder is here.
And this thread shows why using a buggy chunk of code like Jet that hasn't been supported for the past 9 years is such as mistake. With the answer, leave the first line in schema.ini blank.