System.Data Namespace DataTableCollection Class
Checks whether a DataTable string with the specified name exists in the collection.
[ VB ]
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;
- name
- The name of the DataTable to find.
This method returns only a boolean value: true if the specified table exists; otherwise, false.
The property is read only with no default value.
You specify the name of the DataTable object by means of the TableName property. If you add a DataTable to the collection with the Add method, passing no arguments, the table is given a default name, based on the order in which the table was added ( 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 DataTableCollection of a given DataSet.
private void TestForTableName ( DataSet ds ) {
// check if the named table exists.
if ( ds.Tables.Contains ( "Suppliers" ) ) {
// ... do your thing with the table here
}
}
Private Sub TestForTableName ( ByVal ds As DataSet )
' check if the named table exists.
If ds.Tables.Contains ( "Suppliers" ) Then
' ... do your thing with the table here
End If
End Sub |
|
C# |
VB |
DataTableCollection Members IndexOf