Tuesday, July 20, 2010

Read CSV Error: Format of the initialization string does not conform to specification starting

I was trying to read the csv into datatable when i encountered this error.
"Format of the initialization string does not conform to specification starting xx"

Some Googling reveal that its a problem of connection string. The connection string i was using is
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strFolderPath + ";" + "Extended
Properties=’text;HDR=YES;’";

Upon further searching, the particular problem was identified. Basically i was not specifying the CSV Format in the string.

Finally, it is solved by using the following connection string.
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strFolderPath + ";" + "Extended
Properties=’text;HDR=YES;FMT=CSVDelimited’";

No comments: