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
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.
To add a column to a DataTable with the Dataset Designer
Open your dataset in the Dataset Designer. For more information, see How to: Open a Dataset in the Dataset Designer.
Right-click the DataTable to add the column. Point to Add, and then click Column.
Replace the default column name, if desired, by selecting the column name in the data table and editing the text.
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
In the Data Sources window, right-click the data source, and then click Configure DataSet with Wizard.
Expand the table you want to add a column to.
Select the columns to add to the table.
Click Finish.
To add a column to a DataTable with the TableAdapter Configuration Wizard
Open your dataset in the Dataset Designer. For more information, see How to: Open a Dataset in the Dataset Designer.
Right-click the data table, and then click Configure.
Add the column to the SELECT statement.
Click Finish.
See Also
Tasks
Walkthrough: Displaying Data on a Windows Form
How to: Connect to Data in a Database
Concepts
Binding Windows Forms Controls to Data in Visual Studio
Preparing Your Application to Receive Data
Fetching Data into Your Application
Binding Controls to Data in Visual Studio
Editing Data in Your Application