Condividi tramite


Creating and Editing Typed Datasets

The Dataset Designer is a set of visual tools that you can use to create and edit typed datasets and the individual items that they contain.

The Dataset Designer provides visual representations of the objects contained in typed datasets. You create and modify TableAdapters, TableAdapter Queries, DataTables, DataColumns, and DataRelations with the Dataset Designer.

To open the Dataset Designer, double-click a dataset in Solution Explorer, or right-click a dataset in the Data Sources window and click Edit DataSet with Designer. For more information, see How to: Open a Dataset in the Dataset Designer. Adding a new DataSet item with the Add New Item dialog box will open the Dataset Designer with an empty dataset ready for editing.

Note

The Dataset Designer can be used to extend the functionality of a dataset. Double-click the design surface or right-click and choose View Code to create a partial class file where you can add code to the dataset that will not be changed or deleted by the designer. For information on extending the functionality of a TableAdapter, see How to: Extend the Functionality of a TableAdapter.

The following table lists the common tasks you can accomplish with the Dataset Designer.

To

See

Create a TableAdapter

How to: Create TableAdapters

Edit a TableAdapter

How to: Edit TableAdapters

Create a TableAdapter query

How to: Create TableAdapter Queries

Edit a TableAdapter query

How to: Edit TableAdapter Queries

Create a DataTable

How to: Create Data Tables

Edit a DataTable

Designing DataTables

Create a DataColumn

How to: Add Columns to a DataTable

Create a relationship between two DataTables

How to: Create DataRelations with the Dataset Designer

Extend the functionality of the dataset

How to: Extend the Functionality of a Dataset

Add validation to a data table's ColumnChanging event

How to: Validate Data During Column Changes

Add validation to a data table's RowChanging event

How to: Validate Data During Row Changes

Creating Objects on the Design Surface

You can create datasets by adding and editing the individual objects that make up a dataset. The following table provides an explanation of the different objects in the DataSet tab on the Toolbox that can be dragged onto the design surface:

Object

Description

TableAdapter

Contains a collection of data commands and a data connection that are used to communicate with the underlying database and populate a data table. For more information, see TableAdapter Overview and How to: Create TableAdapters.

Query

TableAdapter queries are strongly typed methods that execute SQL statements and stored procedures. Running a TableAdapter query populates a data table with data or performs other database tasks. For more information, see How to: Create TableAdapter Queries. Dragging a query onto a table adds the query to that table, whereas dragging a query onto an empty area of the Dataset Designer creates a global query. For more information, see How to: Add Global Queries to a Dataset.

DataTable

Represents an in-memory collection of the rows returned from a database.

Relation (DataRelation)

Represents a parent-child relationship between two DataTables. For more information, see Introduction to DataRelation Objects and Walkthrough: Creating a Relationship between Data Tables.

Note

The Dataset Designer connects to an underlying database only when a dataset is created; the designer doesn't automatically detect subsequent changes to the database. To refresh an existing .xsd, re-run the Configuration Wizard. If the table relations have changed, remove and re-add the relevant tables to the .xsd.

LINQ to Dataset

LINQ to DataSet enables LINQ (Language-Integrated Query) over data in a DataSet object. For more information, see LINQ to DataSet.

See Also

Tasks

Walkthrough: Creating a Dataset with the Dataset Designer

Walkthrough: Creating a TableAdapter with Multiple Queries

Walkthrough: Creating a DataTable in the Dataset Designer

Walkthrough: Creating a Relationship between Data Tables

Walkthrough: Displaying Data on a Windows Form

Reference

Data Sources Window

Concepts

Working with Datasets in Visual Studio

Preparing Your Application to Receive Data

Fetching Data into Your Application

Editing Data in Your Application

Validating Data

Saving Data