O'Reilly logo

Programming ASP.NET, 3rd Edition by Dan Hurwitz, Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required