Add code to datasets in n-tier applications
You can extend the functionality of a dataset by creating a partial class file for the dataset 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 Classes and Methods.
The code that defines a dataset is generated every time changes are made to the dataset definition (in the Creating and Editing Typed Datasets). This code is also generated when you make changes during the running of any wizard that modifies the configuration of a dataset. To prevent your code from being deleted during the regeneration of a dataset, add code to the dataset's partial class file.
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 filenamed 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 that's named DatasetName.DataSet.Designer.vb (or DatasetName.DataSet.Designer.cs).This file contains the dataset code.
When you separate datasets and
When validation code needs to be added, the Creating and Editing Typed Datasetsprovides functionality for generating ColumnChanging and RowChanging event handlers. For more information, see Add validation to an n-tier dataset.
Locate the project that contains the .xsd file (the Creating and Editing Typed Datasets).
Select the .xsd file to open the Creating and Editing Typed Datasets.
Right-click the data table to which you want to add code (the table name in the title bar), and thenselectView 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 CustomersDataTable in the NorthwindDataSet:
N-Tier Data Applications Overview
Add code to TableAdapters in n-tier applications
Hierarchical Update Overview
Creating Data Applications
Dataset tools in Visual Studio