AddTable Method
The AddTable method adds an existing data table instance into a data set.
Unlike AddNewTable, it does not create a table; it inserts a table that has already been created by the caller.
The method requires that the provided table has a non-empty TableName and that the data set does not already
contain a table with the same name.
/// <summary>
/// Adds table to data set
/// </summary>
/// <param name="dataSet">Data set</param>
/// <param name="tableName">Table name</param>
/// <exception cref="ArgumentException">Exception is thrown if specified table does not have assigned name</exception>
/// <exception cref="KeyDuplicationException">Exception is thrown if a dataset contains a table with specified name already</exception>
public static void AddTable(this IDataSet? dataSet, IDataTable dataTable)
Namespace: PocoDataSet.Data
Assembly: PocoDataSet.Data.dll
dataSet is null, returns immediately.
dataTable.TableName is null or empty, throws ArgumentException.
dataSet.Tables already contains a table with that name, throws KeyDuplicationException.
dataSet.Tables using the table name as the dictionary key.
// 1) Create an empty data set
IDataSet dataSet = DataSetFactory.CreateDataSet();
// 2) Create a table and assign a name
IDataTable departmentDataTable = new DataTable();
departmentDataTable.TableName = "Department";
// 3) Build schema / rows as needed
departmentDataTable.AddColumn("Id", DataTypeNames.INT32);
departmentDataTable.AddColumn("Name", DataTypeNames.STRING);
// 4) Add the table into the data set
dataSet.AddTable(departmentDataTable);
Table of Content POCO DataSet API References POCO DataSet Types DataSet Members
Business Process Programming in .Net
© 2004–2026 Laskarzhevsky Software Inc.
Unless otherwise noted, the content of this website is licensed under the
Creative Commons Attribution 4.0 International License (CC BY 4.0).
Code examples are provided under the MIT License.
You are free to share and adapt the material provided that appropriate
credit is given and any modifications are clearly indicated.
The information provided on this website is for educational purposes only.
The author and publisher make no warranties regarding the completeness
or suitability of the information and are not responsible for any damages
resulting from its use.