Is it possible to stream a csv file into a database in C#?

bulkinsert bulk-load c# sqlbulkcopy

Question

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

1
1
3/18/2011 4:57:46 AM

Accepted Answer

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

1
3/18/2011 5:01:51 AM

Popular Answer

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.



Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow