Multiuser Updates
So far, you have not enabled support for optimistic concurrency . You are now going to go back and check the “use optimistic concurrency” checkbox, but before you do, let’s take a moment to put this concept in context.
As things stand now, you read data from the database and move the data into your data grid through the SqlDataSource
. You have now added the ability to update (or delete) that information. Of course, more than one person may be interacting with the database simultaneously (few web applications support only single-user access).
You can easily imagine that this could cause tremendous problems of data corruption. Imagine, for example, that two people download a record:
Liberty Associates, Inc. / Boston / Jesse Liberty
The first editor changes the City from Boston to New York. The second editor changes the Contact Name from Jesse Liberty to Milo Liberty. Now, things get interesting. The first editor writes back the data record, and the database has the following:
Liberty Associates, Inc. / New York / Jesse Liberty
A moment later, the second editor updates the database. The database then has the following record:
Liberty Associates, Inc. / Boston / Milo Liberty
These earlier updated values are overwritten and lost. The technical term for this is bad.
To prevent this problem, you might be tempted to use any of the following strategies:
Lock the records. When one user is working with a record, other users can read the records but they cannot update them. This is ...
Get Programming ASP.NET, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.