Hierarchical Update
Hierarchical update refers to the process of saving updated data (from a dataset with two or more related tables) back to a database while maintaining referential integrity rules. Referential integrity refers to the consistency rules provided by the constraints in a database that control the behavior of Inserting, Updating, and Deleting related records. For example, it is referential integrity that enforces the creation of a customer record before allowing orders to be created for that customer.
Saving modified data from related data tables is a little more complex than saving data from a single table. This is because the Update, Insert, and Delete commands for each related table have to be executed in a specific order to avoid violating referential integrity constraints. For example, consider an order entry application with which you can manage both new and existing customers and orders. If you have to delete an existing customer, you must first delete all of that customer's orders before deleting the customer record. If you are adding a new customer (with an order), you must first insert the new customer record before inserting that customer's orders because of the foreign key constraints that exist in the tables. As these examples show, you have to extract specific subsets of data and send the updates (Inserts, Updates, and Deletes) in the correct order to maintain referential integrity.
The hierarchical update feature uses a TableAdapterManager to manage the TableAdapters in a typed dataset. The TableAdapterManager component is a Visual Studio—generated component, so it is not part of the .NET Framework. For detailed information about the TableAdapterManager class, see the TableAdapterManager Reference section of TableAdapterManager Overview.
If your application uses typed datasets and gives users the ability to modify the data in related data tables (data tables in a one-to-many relationship such as Customers and Orders), you will probably want to use hierarchical update.
In This Section
Hierarchical Update Overview
Explains what hierarchical update is and provides details about how it is implemented.TableAdapterManager Overview
Explains what a TableAdapterManager is and provides descriptions of the TableAdapterManager code that is generated by the Dataset Designer.How to: Enable and Disable Hierarchical Update
Describes how to set the Hierarchical Update property of a typed dataset to generate code to save related tables.How to: Configure Foreign-Key Constraints in a Dataset
Describes how to configure the constraints in a dataset.How to: Commit In-Process Edits on Data-Bound Controls Before Saving Data
Describes how to stop all in-process edits in data-bound controls on a form to prepare the data source to be saved.How to: Set the Order When Performing a Hierarchical Update
Describes how to set the UpdateOrder property of a TableAdapterManager to control the order in which Inserts, Updates, and Deletes are performed.How to: Implement Hierarchical Update in Existing Visual Studio Projects
Describes how to upgrade an application that has related data tables to save data by using the TableAdapterManager.Walkthrough: Saving Data from Related Data Tables (Hierarchical Update)
Provides step-by-step instructions for creating an application that has related data tables and saving the data by using the TableAdapterManager.
Reference
Related Sections
Working with Datasets in N-Tier Applications