Partager via


DataSet tools in Visual Studio

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Note

Datasets and related classes are legacy .NET technologies from the early 2000s that enable applications to work with data in memory while the applications are disconnected from the database. They are especially useful for applications that enable users to modify data and persist the changes back to the database. Although datasets have proven to be a very successful technology, we recommend that new .NET applications use Entity Framework. Entity Framework provides a more natural way to work with tabular data as object models, and it has a simpler programming interface.

A DataSet object is an in-memory object that is essentially a mini-database. It contains DataTable, DataColumn, and DataRow objects in which you can store and modify data from one or more databases without having to maintain an open connection. The dataset maintains information about changes to its data, so updates can be tracked and sent back to the database when your application becomes reconnected.

Datasets and related classes are defined in the System.Data namespace in the .NET API. You can create and modify datasets dynamically in code using ADO.NET. The documentation in this section shows how to work with datasets by using Visual Studio designers. Datasets that are created through designers use TableAdapter objects to interact with the database. Datasets that are created programmatically use DataAdapter objects. For information about creating datasets programmatically, see DataAdapters and DataReaders.

If your application needs to only read data from a database, and not perform updates, adds, or deletes, you can usually get better performance by using a DataReader object to retrieve data into a generic List object or another collection object. If you are displaying the data, you can data-bind the user interface to the collection.

Dataset workflow

Visual Studio provides tooling to simplify working with datasets. The basic end-to-end workflow is:

Datasets and N-tier architecture

For information about datasets in N-tier applications, see Work with datasets in n-tier applications.

Datasets and XML

For information about converting datasets to and from XML, see Read XML data into a dataset and Save a dataset as XML.

See also