I am working in an application in which user selects some rows in a gridview by clicking on check boxes associated with each row and in selected rows only one value should be updated in database.
I am using following query
update Items
set bitIsTab = 1
where ReqID = 3
Suppose that user selects 4 values from gridview and i have to set these 4 rows bitIsTab to 1.How to update these rows by calling query one time or i have to call the same query as many times as the number of records selected.
Okay the query should look like this, to update items 1,2,3,4:
It can however be done using
Linq:Or you could use a
VARCHARin your stored procedure:And then use “1,2,3,4” as your stored procedure parameter.
To execute the stored procedure:
Could also be done in a more reusable way, with the
bitIsTabas a parameter:And executed this way:
I updated the stored procedure solution, since comparing a
INTwith aVARCHARwon’t work with theEXEC.