
Deleting Data | 175
Data Access
and Binding
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
new DataRow instance, and then set the item values of the new row to the values
in the form fields. Once all values have been set, we add the row to the DataTable
and (outside of the
Select Case statement) call the SqlDataAdapter’s Update
method, which updates the backend database with the new row.
If we’re updating an existing row, we call GetTitleData with a
WHERE clause for
that specific row, set its items to the values in the form fields, and call Update
again to save the changes to the backend database. Once we’ve called Update, we
call Response.Redirect to redirect the user back to the original page, which again
clears the decks and starts from scratch (with the new data, of course).
Example 7-5 demonstrates “last-in-wins” data concurrency. Be
aware that using this type of concurrency control can result in over-
writing changes made by another user between the time data was
queried and when it was updated. In a multi-user environment, you
should always carefully consider the potential costs and effects of
multiple users attempting to update the same data simultaneously
and design your applications accordingly. Strategies can include
locking data from the time it is read until the update is complete, or
using a timestamp before updating to