Bala Nair
3/19/2002 11:00:00 PM
Ok, it's getting better, but still not perfect. I can now read generic CSV
files with and w/o a header row, but it doesn't seem to be able to handle
tab delimited files correctly. Here's what I'm using for connection
strings:
For files with a header row:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\WebSite\Import;Extended
Properties="text;HDR=YES;FMT=Delimited;";"
For file w/o a header row:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\WebSite\Import;Extended
Properties="text;HDR=NO;FMT=Delimited;";"
CSV files work fine, but tab delimited files come out as one column per row
with all the data concatenated. Here's a code snippet for getting the data:
OleDbConnection cnn = new OleDbConnection(m_strCnn);
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.SelectCommand = new OleDbCommand(m_strCmd, cnn);
if (rows == -1)
{
adapter.Fill(dataset, this.m_filename);
}
else
{
adapter.Fill(dataset, 0, rows, this.m_filename);
}
I can get tab delimited files to work if I use a DSN connection and make an
entry in schema.ini for the file I'm going to import. eg.
[test.txt]
ColNameHeader=False
Format=TabDelimited
MaxScanRows=3
CharacterSet=ANSI
[test2.txt]
ColNameHeader=True
Format=TabDelimited
MaxScanRows=3
CharacterSet=ANSI
Any idea what's going on?
Bala Nair
Intranets.com