Export (0) Print
Expand All
2 out of 13 rated this helpful - Rate this topic

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 Table.

NoteNote

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.