none
Import UTF-8 CSV file into Access - programmatically? RRS feed

  • Question

  • I can use MSAcess 2007 to Import a UTF-8 CSV file into a new table. During the Import wizard, I click the Advanced button and set the Code Page to "Unicode (UTF-8)" and the import works beautifully. 

    Now, I want to do the same from VB6. The following code works fine except that the code comes in with ANSI encoding. What is the setting to force Access to import with a CodePage=UTF-8?

    db.Execute "Select * Into Test1 From [Text;FMT=CSVDelimited;HDR=YES;DATABASE=C:\test\].[utf8-test.csv]"

    If it is possible with the MSAccess program/interface, I assume it must be possible programmatically; I just can't figure out what the equivalent parameter is for the code above.

    Thanks,

    Jeff


    • Edited by JJJones3860 Friday, November 13, 2015 5:11 PM typo
    Friday, November 13, 2015 5:09 PM

Answers

  • I found the answer in StackOverflow - sort of. The documentation states that the "CharacterSet" parameter only accepts values of "ANSI" and "OEM". I tried "UTF-8" and "Unicode (UTF-8)" to no avail. But in StackOverflow, a post stated that the code for UTF-8 is 65001.

    So I amended the code about to include "CharacterSet=65001;" and it is now working!

    Perhaps this will save others some time.

    Jeff

    • Marked as answer by JJJones3860 Friday, November 13, 2015 5:31 PM
    Friday, November 13, 2015 5:31 PM