How to lock the record before editing

  • Thread starter Thread starter Ellis Yu
  • Start date Start date
E

Ellis Yu

Dear all,

I have a module of application for updating a record from serveral
tables and I used optimistic locking at the beginning, but the feedback is
user feel frustrated when they knew the records can't be saved since it had
been updated by others after they input all the information on it. So they
perferred to knew anyone is updating the record before they start to input
the information. I'm newbie on ado.net. Anyone know how to do it or any
better way to handling this? I would highly appreciate for any help. Thanks

Best Rdgs
Ellis
 
Ellis,

Adonet is based on disconnected use of the data.

However noboby prevents you from using all SQL commands, where you can use
commands like the execetenonquery's and the datareaders.

Be aware that you should create handling for when a user disconnects
withouth login off to prevent deadlocks.

Just my thought,

Cor
 
They are going to be much more unhappy when the record stay locks for hours
and days until the dba goes unlocks the record, because there was some issue
and the record was never released.

Why are the users not only working on the record so much, but updating the
same fields? Why would 2 of them both update the Address field, for example
at the same time? That seems odd. If your code only has the PK and the
columns being updated in the WHERE clause, then as long as users are working
on different columns, even on the same record, it should be fine.

If this doesn't work because users are updating the same field on the same
record, what you can do, is maybe add a datestamp column to your table to
track the last time this record was 'locked'. When a user is done with the
record, clear out the field. If a user wants the record and if the date
stamp says the record has been locked for more then an hour, say, then
update the value of the datestamp field and allow the new user access to the
table. And use optimistic concurrency, so that in case user 1 left for 2
hours and then came back and tries to update the record, that there is a
check to see if the record has been updated since.
 
Back
Top