views:

220

answers:

1

I am using Microsoft.Jet.OLEDB.4.0 from .NET to read a CSV file. Here is a sample input data row:

102A Avenue,97 Street,99 Street,2 Lanes Closed,2007-04-13,2009-12-31

When I read the last two valuee they come out as DateTime rather than strings and that is neither what I want nor what I expect. It seems that the provider performs type inference on text values. Is there a way to disable that?

Thanks,

-Vlad

A: 

When you create your connection string, use "Text;HDR=YES;FMT=Delimited;IMEX=1" in the Extended Properties, like this:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\example.csv;Extended Properties='text;HDR=Yes;FMT=Delimited'

HDR=YES means use the first row as a header row, so edit that as appropriate.

Don
I am using that exact connection string.
Vlad