Add code to TableAdapters in n-tier applications
You can extend the functionality of a
TableAdapter by creating a partial class file for the
TableAdapter and adding code to it (instead of adding code to the DatasetName.DataSet.Designer file). Partial classes enable code for a specific class to be divided among multiple physical files. For more information, see Partial or partial (Type).
The code that defines a
TableAdapter is generated every time changes are made to the
TableAdapter (in the Creating and Editing Typed Datasets). This code is also generated when changes are made during the running of any wizard that modifies the configuration of the
TableAdapter. To prevent your code from being deleted during the regeneration of a
TableAdapter, add code to the partial class file of the
By default, after you separate the dataset and
TableAdapter code, the result is a discrete class file in each project. The original project has a file named DatasetName.Designer.vb (or DatasetName.Designer.cs) that contains the
TableAdapter code. The project that's designated in the Dataset Project property has a file named DatasetName.DataSet.Designer.vb (or DatasetName.DataSet.Designer.cs) that contains the dataset code.
When you separate datasets and
The Creating and Editing Typed Datasets provides functionality for generating ColumnChanging and RowChanging event handlers when validation is needed. For more information, see Add validation to an n-tier dataset.
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Personalizing the IDE.
Locate the project that contains the .xsd file (the Creating and Editing Typed Datasets).
Double click the .xsd file to open the Creating and Editing Typed Datasets.
TableAdapterthat you want to add code to, and then selectView Code.
A partial class is created and opens in the Code Editor.
Add code inside the partial class declaration.
The following example shows where to add code to the