How in .Net do I Import Values from a CSV in the format I want using OleDB?

佐手、 提交于 2019-12-01 21:55:44

Try to use GetString() method in the reader when you need to read the column as string:

string myStringValue = reader.GetString(0);

Do you have control of the export process? If so can data be exported to CSV with quotes around the string items?

If this is a one of job then just import the file into a predfined SQL table using Integration Services, but I suspect this will be a recurring task.

There's a Schema.ini file that needs to be used to specify the info about the file. It includes field types and lengths, whether there are column headers and what the field delimiter is.

Here's the MSDN Info on it.
http://msdn.microsoft.com/en-us/library/ms709353.aspx

Have you tried using this CSV reader? It is generally very respected. Perhaps give it a go...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!