[RESOLVED] connection string to .CSV
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & path & ";Extended Properties=""text;HDR=No;FMT=Delimited( ; )"""
i see data .. but the seperation by semicolon is not working .. what do i need to change?
(extra spaces for ; .. cause of smilies)
Re: connection string to .CSV
Do you mean that you file is actually semi-colon delimited instead of comma?
Re: connection string to .CSV
yes .. my file has a semi-colon in it ( ; )
Re: connection string to .CSV
Have you tried this?
Code:
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & path & ";Extended Properties=""text;HDR=Yes;FMT=Delimited;"""
I am not sure if you are aware of this site or not:
http://www.connectionstrings.com/textfile
Good Luck and hope this helps!
D
Re: connection string to .CSV
yes .. tried it .. not working
when i change the layout from ; to , .. then its working .. but i really need a ; and not a ,
Re: connection string to .CSV
found it ..
need to create a schema.ini file .. on the same location .. containting:
[test.CSV]
ColNameHeader=False
CharacterSet=ANSI
Format=Delimited( ; )
Re: connection string to .CSV
Cool, good job! Where did you find that info? And dont forget to mark the issue resolved!!
D
Re: connection string to .CSV
Don't use ADO.Net in your case then. With ADO.Net, it uses the system's default delimiter and unless you've changed it, that default delimiter is the comma. You can change it in registry, but I strongly suggest that you DON'T do it. You can also create a schema for the file, but it needs to be in the same folder as the file, and if you have many of those delimited files to parse, it's going to be very tedious to create the schemas for them all.
Instead, have a look at the TextFieldParser class which you can set its Delimiters property to tell the object what the delimiters are in the file.
Re: connection string to .CSV
found it on google somewhere .. i thought .. this is never gonna work .. but i was kind of desperate :)
Thanks for the tip stanav .. might look into that TextFieldParser..