Adds the specified table to the collection.
[Visual Basic] Overloads Overridable Public Sub Add( _ ByVal table As DataTable _ ) [C#] public virtual void Add( DataTable table ); [C++] public: virtual void Add( DataTable* table ); [JScript] public function Add( table : DataTable );
Exception Type | Condition |
---|---|
ArgumentNullException | The table is a null reference (in Visual Basic Nothing). |
ArgumentException | The table already belongs to this collection, or belongs to another collection. |
DuplicateNameException | A table in the collection has the same name. The comparison is not case-sensitive. |
The OnCollectionChanged event occurs when a table is succefully added.
The following example creates a DataTable and adds it to the TablesCollection of a DataSet.
[Visual Basic]
Private Sub AddDataTable() Dim tablesCol As TablesCollection ' Get the TablesCollection of a DataGrid control's DataSet. Set tabelesCol = DataGrid1.DataGridTable.DataTable.DataSet.Tables ' Create a new DataTable. Dim myTable As DataTable = New DataTable ' Code to add columns and rows not shown here. ' Add the table to the TablesCollection. tablesCol.Add myTable End Sub
TablesCollection Class | TablesCollection Members | System.Data Namespace | TablesCollection.Add Overload List | DataTable | Remove | Clear