How to: Add Columns to a DataTable

The individual columns (DataColumn) that make up data tables (DataTable) are created by adding them to the data tables DataColumnCollection. You can add columns to data tables visually with the Dataset Designer, or with one of the data wizards. To add data columns to data tables programmatically, see Adding Columns to a DataTable (ADO.NET).

Note

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

To add a column to a DataTable with the Dataset Designer

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

  2. Right-click the DataTable to add the column. Point to Add, and then click Column.

  3. Replace the default column name, if desired, by selecting the column name in the data table and editing the text.

  4. Set the DataType property in the Properties window. For more information, see How to: Set the Data Type of a DataColumn.

To add a column to a DataTable with the Data Source Configuration Wizard

  1. In the Data Sources window, right-click the data source, and then click Configure DataSet with Wizard.

  2. Expand the table you want to add a column to.

  3. Select the columns to add to the table.

  4. Click Finish.

To add a column to a DataTable with the TableAdapter Configuration Wizard

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

  2. Right-click the data table, and then click Configure.

  3. Add the column to the SELECT statement.

  4. Click Finish.

See Also

Tasks

Walkthrough: Displaying Data on a Form in a Windows Application

How to: Connect to Data in a Database

Concepts

TableAdapter Overview

Dataset Designer

Displaying Data Overview

Other Resources

Connecting to Data in Visual Studio

Preparing Your Application to Receive Data

Fetching Data into Your Application

Displaying Data on Forms in Windows Applications

Editing Data in Your Application

Validating Data

Saving Data