I have a SqlDataSource
that I would like to use for updating. I would be using two similar update commands, and I was wondering how I could do this in one SqlDataSource
. I know how to do 'normal' parameters, but I was wondering how I could change what was being updated as well as how it's being updated. Here are my statements as I would put them into the SqlDataSource
:
UPDATE Part SET checkbox02 = @val WHERE partnum = @partnum
UPDATE Part SET checkbox03 = @val WHERE partnum = @partnum
But, I can only have one UpdateCommand
per SqlDataSource
.
Is it possible to do something like this:
UPDATE Part SET @checkbox = @val WHERE partnum = @partnum
where I can change @checkbox
and have it update either checkbox02
or checkbox03
depending on what I set the parameter to? Determination of @checkbox
would be happening in the code-behind.
If this is not possible, what is the best alternative to minimize code/memory usage?
UpdateCommand="UPDATE Part SET checkbox02 = @val02, checkbox03 = @val03 WHERE partnum = @partnum"
and then set the parameter that I don't want to change to the appropriate column name? For example, say I don't want to changechekcbox02
this time, so I set the@val02
parameter tocheckbox02
.checkbox02
to data typetinyint
(the checkbox data types)