Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Connection string for reading csv file?

$
0
0

I am trying to read a .Csv file in c#.net framework 4.0 and facing problem with connection string. First i tried this:

connectionString="Provider=Microsoft.ACE.OLEDB.12.0;DataSource={0};ExtendedProperties='Excel 12.0 Xml;HDR=YES;IMEX=1;'"

but it shows the error:

External table is not in the expected format.

I think this can be only used for reading .xlsx file and i have tried this for reading .xlsx file and it is working.

Then i tried this:

connectionString="Provider=Microsoft.Jet.OLEDB.4.0;DataSource={0};ExtendedProperties='text;HDR=Yes;FMT=Delimited'";

But it shows the error:

'F:\path\of the\file\filename.csv'is not a valid path.Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.

Where i am doing mistake?

Thanks in advance.


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>