How to specify the delimiter when importing CSV files via OLEDB in C#

前端 未结 3 1765
你的背包
你的背包 2020-12-03 15:59

I need to perform a complex import in a Microsoft SQL Server 2000.

Since doing it in a DTS is too complicated, I\'m trying to do it with a little C# program, but I\'

相关标签:
3条回答
  • 2020-12-03 16:29

    You have to write your csv file name inside the schema.ini file (not [file.csv], e.g.: test.csv will have a schema.ini with [test.csv] text at line 0:

    [test.csv]
    Format=Delimited(;)
    
    0 讨论(0)
  • 2020-12-03 16:31

    Commenter is right that you have your provider syntax the wrong way round.

    However, this isn't the problem. Unfortunately, you cannot specify a custom delimiter in your oledb connection string. Instead, create a schema.ini file in the same directory as your source file containing the following:

    [file.csv]
    Format=Delimited(;)
    

    Clumsy, but it does work.

    0 讨论(0)
  • 2020-12-03 16:46

    The schema.ini file has to be saved in Unicode or ANSI, not as UTF-8.

    Your data file must also be saved as Unicode not UTF-8.

    0 讨论(0)
提交回复
热议问题