Share via


How to: Create DataTables

Data can be stored in memory in DataTable objects. (Datasets are made up of DataTable objects.) You typically create new data tables with TableAdapters using the TableAdapter Configuration Wizard or by dragging database objects from Server Explorer onto the Dataset Designer.

Data tables are created as a byproduct when you create new TableAdapters in the Data Source Configuration Wizard as well, but they can also be created independently. You create a standalone data table by dragging a DataTable object from the DataSet tab of the Toolbox onto the Dataset Designer.

Note

To create data tables programmatically, see Creating a DataTable (ADO.NET).

Note

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 Visual Studio Settings.

Creating a DataTable with TableAdapter

Data tables with TableAdapters include methods that fill the table with data and write changes back to the database. You create TableAdapters by running the TableAdapter Configuration Wizard or by dragging database objects from Server Explorer onto the Dataset Designer.

To create a new data table with TableAdapter

  1. Open your dataset in the Dataset Designer. For information, see How to: Open a Dataset in the Dataset Designer.

  2. Drag a TableAdapter from the DataSet tab of the Toolbox onto the Dataset Designer.

    The TableAdapter Configuration Wizard opens.

  3. Complete the wizard. For more information, see TableAdapter Configuration Wizard

To create a new data table with a TableAdapter from Server Explorer

  1. Open your dataset in the Data Source Designer.

  2. Drag a database object (for example, a table) from Server Explorer onto the Dataset Designer.

Creating a Standalone DataTable

Standalone tables need to have Fill logic implemented in order to be filled with data. For information on filling standalone data tables, see Populating a DataSet from a DataAdapter (ADO.NET).

To create a new stand alone data table

  1. Open your dataset in the Dataset Designer.

  2. Drag a DataTable from the DataSet tab of the Toolbox onto the Dataset Designer.

  3. Add columns to define your data table. For more information, see How to: Add Columns to a DataTable.

See Also

Tasks

Walkthrough: Displaying Data on a Windows Form

How to: Connect to Data in a Database

Reference

Data Sources Window

DataTable

Concepts

What's New in Data Application Development

TableAdapter Overview

Dataset Designer

Data Sources Overview

Validating Data

Other Resources

Data Walkthroughs