c# - How can I safely exit a DBMS when records are locked? -


i'm hobbyist programmer have been doing while. i'm writing small document management application use @ work (in c#). when user opens record, update indicate it's locked editing.

what i'm not sure how ensure database gets updated when application exits unsafely (eg. computer shuts down unexpectedly)? also, how should update when application exits via computer being shut down user? want make sure don't end records being marked locked when nobody viewing them.

here's how done sql server. developer-issued "record locks" not relevant client-server architecture. confusing shared-file architecture client-server architecture.

make sure table has timestamp column (which automatically updated database engine).

read in row want edit. put timestamp row in variable.

update statement looks this:

update mytable set col = {some value} id = {your id} , timestampcolumn = {the timestamp row had when read in} 

if has changed row since read in, have different timestamp , no record match clause conditions, , update fail. can decide do.

you can pull plug on client pc when you're using sql-server (or oracle or true client-server architecture) without having adverse impact on server.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -