views:

53

answers:

3

Hi all

Here is my situation:

I use the SqlCommond to update some records in the SQL Server in a ASP.NET web site. Users can choose which records they want to update. Sometimes they may choose 40 or 60 records to update at a time.Is there any good way to do it? I do not want to do like it

foreach(string ID in List)
{
   Update here
} 

Best Regards,

+3  A: 

You can send one SQL string ith all the update statements together. Nothing says a SQL "round trip" can not execute multiple statements or even multiple batches.

TomTom
That is correct, but that doesn't change anything. Besides - SqlCommand will not execute GO commands. This is only possible in SMO.
kubal5003
A: 

update table set..........where condition

That's possible only with records that match certain condition - usually user selected records don't.
kubal5003
+1  A: 

yes we can do thing in one round tip. create xml string of the selected id and pass to the procedure as and Varchar(max) argument.

and in sql part use openXml and update data.

check th post : http://www.sqlservercentral.com/articles/OpenXML/usingopenxml/1881/

Pranay Rana