asp.net.ph

DataTableCollection.Contains Method ( String )

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;

Parameters

name
The name of the DataTable to find.

Return Value

This method returns only a boolean value: true if the specified table exists; otherwise, false.

The property is read only with no default value.

Remarks

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.

Example

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
    }
}
  C# VB

See Also

DataTableCollection Members   IndexOf Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph