Updating ADO.NET

Chapter 19 demonstrated how to retrieve data from a database and display it in various ways. In many cases, you will also want to allow the user to interact with your application to modify the data, and you must write these changes back to the database.

Two aspects to writing applications allow users to update data. The first is to provide the user with controls to modify the data. Methods to enter the proposed changes include the use of controls such as listboxes and radio buttons for making selections and text boxes for editing text entries. You'll find extensive coverage of these controls in Chapters 5 through 9.

Once you know what changes the user wants to make, your program must then provide code for updating the database. To keep the focus on the database issues, the examples in this chapter show very little of the user interface. Many examples use hardcoded data changes; others use a quick and dirty form for updating the data tables.

Updating data in a database is simple if you update only a single table, but things can be more complicated once you update related tables. This chapter explores how transactions ensure your data's integrity.

Since your program may be used by more than one user at a time, you will encounter issues with concurrency: is it possible for one user's changes to overwrite the changes of another user? This chapter explores how to manage concurrency issues and shows some of the powerful support available in the .NET Framework that simplifies this difficult task.

Категории