Adds a DataTable object to the collection.
Creates a new DataTable object with a default name and adds it to the collection.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Overridable Function Add() As DataTable
[C#] public virtual DataTable Add();
[C++] public: virtual DataTable* Add();
[JScript] public function Add() : DataTable;
Adds the specified DataTable to the collection.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Overridable Sub Add(DataTable)
[C#] public virtual void Add(DataTable);
[C++] public: virtual void Add(DataTable*);
[JScript] public function Add(DataTable);
Creates a DataTable object with the specified name and adds it to the collection.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Overridable Function Add(String) As DataTable
[C#] public virtual DataTable Add(string);
[C++] public: virtual DataTable* Add(String*);
[JScript] public function Add(String) : DataTable;
[Visual Basic, C#] The following example adds a DataTable with the given name to the DataTableCollection.
[Visual Basic, C#] Note This example shows how to use one of the overloaded versions of Add. For other examples that might be available, see the individual overload topics.
[Visual Basic] Private Sub AddTable() Dim dSet As DataSet Dim dt As DataTable ' Presuming a DataGrid is displaying more than one table, get its DataSet. dSet = CType(DataGrid1.DataSource, DataSet) ' Use the Add method to add a new table with a given name. dt = dSet.Tables.Add("myNewTable") ' Code to add columns and rows not shown here. MessageBox.Show(dt.TableName) MessageBox.Show(dSet.Tables.Count.ToString()) End Sub [C#] private void AddTable() { DataSet dSet; DataTable dt; // Presuming a DataGrid is displaying more than one table, get its DataSet. dSet = (DataSet)DataGrid1.DataSource; // Use the Add method to add a new table with a given name. dt = dSet.Tables.Add("myNewTable"); // Code to add columns and rows not shown here. MessageBox.Show(dt.TableName); MessageBox.Show(dSet.Tables.Count.ToString()); }
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
DataTableCollection Class | DataTableCollection Members | System.Data Namespace