English 中文(简体)
Microsoft.Jet.OLEDB.4.0 provider turns string into a date
原标题:

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

问题回答

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.





相关问题
ADO.NET Entity Data Model are not precise enough

I run this code: var cos = from k in _db.klienci_do_trasy where k.klient_id == 5 select k; but the query send to database is: SELECT * FROM `klienci_do_trasy` LIMIT 0, 30 why is it for, there ...

Synchronising SQL database through ADO.Net

The problem that i m having is how can i synchronise my datasets in my VS 2008 project to any changes in the database. As you know we read data from the db into the dataset which is disconnected, now ...

ADO.NET Data Services - Uploading files

I am trying to write REST web service through which our clients can upload a file on our file server. IS there an example or any useful links which I can refer for any guidance? I haven t seen many ...

How can I know if such value exists in database? (ADO.NET)

For example, I have a table, and there is a column named Tags . I want to know if value programming exists in this column. How can I do this in ADO.NET? I did this: OleDbCommand cmd = new ...

热门标签