Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 .NET 中的 Microsoft.Jet.OLEDB.4.0 来读取 CSV 文件。这是一个示例输入数据行:
102A Avenue,97 Street,99 Street,2 Lanes Closed,2007-04-13,2009-12-31
当我阅读最后两个值时,它们显示为 DateTime 而不是字符串,这既不是我想要的,也不是我所期望的。提供者似乎对文本值执行类型推断。有没有办法禁用它?
谢谢,
-弗拉德
创建连接字符串时,请在扩展属性中使用“Text;HDR=YES;FMT=Delimited;IMEX=1”,如下所示:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\example.csv;Extended Properties='text;HDR=Yes;FMT=Delimited'
HDR=YES 表示将第一行用作标题行,因此请根据需要进行编辑。