Dataset tools in Visual Studio
Datasets and related classes are legacy .NET technologies from the early 2000s that enable applications to work with data in memory while 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 the Entity Framework. The Entity Framework provides a more natural way to work with tabular data as object models, and has a simpler programming interface.
A DataSet 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 Framework class library. You can create and modify datasets dynamically in code; for more information about how to do that, see ADO.NET. The documentation in this section shows how to work with datasets with Visual Studio designers. One thing to know: Datasets made with designers use TableAdapters to interact with the database, whereas Datasets made programmatically use DataAdapters. For information against creating DataSets programmatically, see DataAdapters and DataReaders
If your application only needs to read data from a database, and not perform updates, adds, or deletes, then you can usually get better performance by using a DataReader to retrieve data into a generic List or other collection object. If you are displaying the data, you can data-bind the user interface to the collection.
Visual Studio provides a lot of tooling to simplify working with datasets. The basic end-to-end workflow is:
Use the Data Source Window to create a new dataset from one or more data sources. Use the Dataset Designer to configure the dataset and set its properties. For example, you need to specify which tables from the data source to include, and which columns from each table. Choose carefully to conserve the amount of memory the dataset will require. See Creating and configuring datasets in Visual Studio
Specify the relationships between the tables so that foreign keys are handled correctly. See Filling datasets by using TableAdapters
Use the TableAdapter Configuration Wizard to specify the query or stored procedure that will populate the dataset, and what database operations (update, delete, and so on) to implement. See these topics:
Use the Data Sources window to bind user-interface controls to the dataset or its individual columns, and specify which columns are user-editable. See Binding controls to data in Visual Studio
For information about datasets in N-Tier applications, see Working with datasets in N-tier applications