Results 1 to 9 of 9

Thread: [RESOLVED] connection string to .CSV

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2008
    Posts
    267

    Resolved [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)
    Last edited by Amien; Dec 9th, 2008 at 09:49 AM.

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: connection string to .CSV

    Do you mean that you file is actually semi-colon delimited instead of comma?
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2008
    Posts
    267

    Re: connection string to .CSV

    yes .. my file has a semi-colon in it ( ; )

  4. #4
    Fanatic Member
    Join Date
    Aug 2006
    Location
    In my head
    Posts
    913

    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
    Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP

    Please Rate If I helped you.
    Please remember to mark threads as closed if your issue has been resolved.

    Reserved Words in Access | Connection Strings

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2008
    Posts
    267

    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 ,

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2008
    Posts
    267

    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( ; )

  7. #7
    Fanatic Member
    Join Date
    Aug 2006
    Location
    In my head
    Posts
    913

    Re: connection string to .CSV

    Cool, good job! Where did you find that info? And dont forget to mark the issue resolved!!

    D
    Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP

    Please Rate If I helped you.
    Please remember to mark threads as closed if your issue has been resolved.

    Reserved Words in Access | Connection Strings

  8. #8
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    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.
    Last edited by stanav; Dec 9th, 2008 at 10:24 AM.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2008
    Posts
    267

    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..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width