Reading Comma Delimited Text File to C# DataTable, columns get truncated to 255 characters

后端 未结 6 1834
我寻月下人不归
我寻月下人不归 2021-02-10 21:14

We are importing from CSV to SQL. To do so, we are reading the CSV file and writing to a temporary .txt file using a schema.ini. (I\'m not sure yet exactly why are are writing t

6条回答
  •  [愿得一人]
    2021-02-10 21:43

    My inclination would be to create the DataTable directly when reading the CSV file, rather than going through the extra step of writing the data out to a different text file, only to read it back into memory a second time.

    For that matter, how are you ultimately getting the data from the DataTable into the SQL database? If you're just looping through the DataTable and doing a bunch of INSERT statements, why not skip two middlemen and call the same INSERT statements while you're initially reading the CSV file?

提交回复
热议问题