asp.net - update value only when changed -


i had around couldn't quite find answer one: got stored procedure updates around 30 fields on sql server 2008 table. it's important me 1 of fields getting updated, if value changed.

the stored procedure snippet @ moment:

alter procedure test @p_roomno int, [roomno] = @p_roomno, 

i tried changing particular column coalesce / isnull in set-clause of procedure, still updates column

[roomno] = coalesce(@p_roomno,roomno), [roomno] = isnull(@p_roomno,roomno), 

both give me same output ...

do have ideas how not update value on server side or have put on .asp-forum change application not pass on values unchanged?

thanks input!

i think proper place check whether values changed prior storing new value in asp side of solution, not in database. , can pass parameter stored procedure.

in procedure, base on parameter, decide whether should change value or not.

edit: suppose have server control of hiddenfield type.

page_load(object sender, eventargs e) {     if (ispostback) {         if (mytextboxiwannacheckforchanges.text != myhiddenfield.value) {             // value has changed.         }     } } 

note check changes during page load. use kind of logic while handling button click (if so, don't have check postback). this:

foo_clicked (object sender, eventargs args) {     sqlcommand command = // ...snip     // ... set need command.     bool changed = (mytextboxiwannacheckforchanges.text != myhiddenfield.value);     command.parameters.addwithvalue("@changed", changed);     // ... let command execute. } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -