Reputation: 4152
In asp.net web site, We have enry form which can be accessible to administrator.
There are more then one administrator for entry. If all admin open form simultaneous and select some combobox value from form then how can we maintained concurrency
Because once first admin select value from combox and save then that value should remove from database.
But how can the problem of concurrency solve when let say two or three admin simultaneous save same value.
Where is right place code or at database? and how?
Upvotes: 0
Views: 339
Reputation: 29157
You should read about optimistic concurrency control. Really it boils down to choosing between optimistic, pessimistic and last one wins. Usually the right choice is optimistic, unless it is a very time consuming process where failure for another user at the end would be frustrating.
As for the right place you need to tell how you are currently doing your Data Access Code. Also what database are you using?
This article will give you something to get started with.
Upvotes: 1
Reputation: 9144
A common technique for implementing concurrency is to use a timestamp for updates, with you, as the developer writing code depending on your business process. Normally, the choices you have are: Last one in wins, so the last write wins, notify the user of the conflict and let them make the choice as to whether or not they wish to commit their changes, or merge the changed values.
This last technique isn't common with databases, as it means that the user commits one set of values, but a different set are updated, and this might come as a surprise to them (also, it requires complex rules). If you think about the way some source control providers work though, you can see how this is implemented.
In the case of a delete operation, there's no need to worry because does it really matter that two users deleted the same record? The second one will have no effect.
Upvotes: 0
Reputation: 15158
In our app we handle it in both:
All our updates goes through a update-stored procedure. This sp thows an error when the field "Modified", what is mandetory, is newer then the given one. The error is thrown by a special exception class in the code and you can identify it as a concurrency exception.
E.g.:
Upvotes: 0