Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch SQL inserts in .NET

Tags:

Is using the .NET DataAdapter's batch insert features any more efficient, as far as DB round-trips, compared to using DbCommand.ExecuteNonQuery() in a loop?

Coming from the Java world, I was hoping to find something similar to it's batch abilities where multiple SQL commands are sent to the database and executed in one operation. When monitoring the database server, I see the DataAdapter making one execute per insert.

I've read a few topics that use the SqlBulkCopy but that's only going to work for MS Sql Server.

Thanks!

like image 644
Eric Tuttleman Avatar asked Jun 09 '09 14:06

Eric Tuttleman


1 Answers

The DataAdapter has a UpdateBatchSize property. Setting the UpdateBatchSize to a positive integer value causes updates to the database to be sent as batches of the specified size.

Hope this helps...

like image 98
Vasu Balakrishnan Avatar answered Oct 12 '22 21:10

Vasu Balakrishnan