2009-10-16 60 views
0

我有許多行更新/插入使用TableAdapter s的SQL Server數據庫。有沒有辦法將它們批處理在一起,以便它仍然是一個UPDATE語句的列表,至少它只是一個遠程調用數據庫的方式?C#數據集批量更新

如果我手動編寫SQL,這將是一個單一的SqlCommand對象與CommandText看起來是這樣的:

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 

那我就只是叫SqlCommand.ExecuteNonQuery();

回答