Checks if a table, specified by name, exists in the collection.
[Visual Basic] Overloads Public Function Contains( _ ByVal name As String _ ) As Boolean [C#] public bool Contains( string name ); [C++] public: bool Contains( String* name ); [JScript] public function Contains( name : String ) : Boolean;
true if the specified table exists; otherwise, false.
The DataTable object's name is specified by the TableName property. If you add a DataTable to the TablesCollection with the Add method, passing no arguments, the table is given a default name such as Table1, Table2, and so on.
To get the index of a DataTable, use the IndexOf method.
The following example tests whether a table with the name "Suppliers" exists in the TablesCollection.
[Visual Basic]
Private Sub TestForTableName() Dim dSet As DataSet ' Get the DataSet of a DataGrid. Set dSet = DataGrid1.DataGridTable.DataTable.DataSet ' Get the TablesCollection through the Tables property. Dim tablesCol As TablesCollection Set tablesCol = dSet.Tables ' Check if the named table exists. If tablesCol.Contains("Suppliiers") Then MessageBox "Table named Suppliers exists" Ene If End Sub
TablesCollection Class | TablesCollection Members | System.Data Namespace | TablesCollection.Contains Overload List | Item | IndexOf | Remove | CanRemove