Since ADO.Net uses a ‘disconnected’ model where the data available to a single program is just a copy of what is in the database, what is the normal way to handle multiple programs needing to update the same table in a database? The problem I see is that a program can’t update unless his copy of the data is the most up-to-date. Are we supposed to read before updating and hope that the update occurs before someone else changes the data?
Since ADO.Net uses a ‘disconnected’ model where the data available to a single program
Share
I would guess the most common way is through Optimistic Concurrency Control. This type of currency control works well in systems where contention for the same data is unlikely.
Optimistic Concurrency in ADO.NET (MSDN)
I normally implement Optimistic Concurrency Control by using a timestamp column in SQL Server. The timestamp column is updated with a new value each time a row is updated. When you want to update a row, you first check its timestamp to see if it matches your local copy. If it has changed, you generally tell the user that a concurrency violation has occurred and provide some type of resolution, such as allowing the user to decide which version to keep (local version or database version).