views:

99

answers:

1

I have a number of rows to update/insert to a SQL Server database using TableAdapters. Is there a way to batch them together, so that while it's still a list of UPDATE statements, at least it's only one remote call to the database?

If I was writing SQL manually, it would be a single SqlCommand object with a CommandText that looks something like this:

update mytable set col = val where id = 1
update mytable set col = val where id = 2
update mytable set col = val where id = 3
...
update mytable set col = val where id = 432

Then I would just call SqlCommand.ExecuteNonQuery();

+2  A: 

Set your adapter's UpdateBatchSize Property. See http://msdn.microsoft.com/en-us/library/aadf8fk2.aspx

Manu
Lovely, thanks.
Neil Barnwell