Joda Maki Joda Maki - 1 year ago 102
C# Question

Best way to Bulk Insert from a C# DataTable

I have a

that I want to push to the DB. I want to be able to say like


But after reading the MSDN docs, apparently this does inserts row by row.

It should be noted that these statements are not performed as a batch process; each row is updated individually.

What are my alternatives?

Edit: I am using SQL Server 2005

Answer Source

If using SQL Server, SqlBulkCopy.WriteToServer(DataTable)

Or also with SQL Server, you can write it to a .csv and use BULK INSERT

If using MySQL, you could write it to a .csv and use LOAD DATA INFILE

If using Oracle, you can use the array binding feature of ODP.NET

If SQLite:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download