C# - is there a way to stream a csv file into data

2019-07-28 15:52发布

I saw lots of articles talking about using SqlBulkCopy to copy content from csv into database, but they all need to load the data into a data table or data set.

this is no good for me, since i deal with large amount of data, and i dont have powerful machine.

is there a way to stream data from the csv into database?

Thanks

2条回答
成全新的幸福
2楼-- · 2019-07-28 16:03

The simplest approach would probably be to read the CSV file line-by-line and execute an SQL INSERT command to add the data to the appropriate table in the database.

查看更多
神经病院院长
3楼-- · 2019-07-28 16:18

This article does show how to load the data directly to the database, without using a temp data table/ data set.

C# - CSV Import Export

Just look for the moethod SaveToDatabaseDirectly

查看更多
登录 后发表回答