Accept Changes and the Update Process

One important point to bear in mind is how the update process affects the Original and Current values of the rows in the tables in a DataSet. Once the DataAdapter.Update process is complete (in other words all the updates for all the rows have been applied), the AcceptChanges method is called for those rows automatically. So, after an update, the Current values in all the rows are moved to the Original values.

However, during the update process (as you can see from our example), the Current and Original values are available in both the RowUpdating and the RowUpdated events. Therefore we can use these events to monitor changes and report errors (we'll see more in a later example).

The techniques we've used in this section of the chapter (and in earlier examples) work fine in circumstances where there are no concurrent updates taking place on the source data. In other words, there is only ever one user reading from and writing to any particular row in the tables at any one time. However, concurrency rears its ugly head in many applications and can cause all kinds of problems if you aren't prepared for it. It's also the topic of the next section.

0 0

Post a comment