System.Data.Common Namespace DataTableMappingCollection Class
Checks whether a DataTableMapping with the given source table name exists in the collection.
[ VB ]
NotOverridable Overloads Public Function Contains ( _
ByVal sourceTable ( ) As String _
) As Boolean Implements ITableMappingCollection.Contains
[ C# ]
public bool Contains (
string sourceTable
);
[ C++ ]
public: __sealed bool Contains (
String* sourceTable
);
[ JScript ]
public function Contains (
sourceTable : String
) : Boolean
- sourceTable
- The case-sensitive name of a SourceTable to find.
This method returns only a boolean value: true if the collection contains a DataTableMapping with the specified source table name; otherwise, false.
ITableMappingCollection.Contains
Use the Contains method to confirm the existence of a table mapping object before performing further operations on the object.
The following example searches for a DataTableMapping object with the given source table name within a DataTableMappingCollection. If the DataTableMapping exists, the code displays the name and index of the mapping; otherwise, it displays an error.
public void FindDataTableMapping ( DataAdapter myAdapter ) {
// get table mappings
DataTableMappingCollection myTables = myAdapter.TableMappings;
if ( myTables.Contains ( "Employees" ) ) {
MessageBox.Show ( "Name: " + myTables [ "Employees" ].ToString ( )
+ "\nIndex: " + myTables.IndexOf ( "Employees" ).ToString ( ) );
} else {
MessageBox.Show ( "Error: no such table in collection" );
}
}
Public Sub FindDataTableMapping ( ByVal myAdapter As DataAdapter )
' get table mappings
Dim myTables As DataTableMappingCollection = myAdapter.TableMappings;
If myTables.Contains ( "Employees" ) Then
MessageBox.Show ( "Name: " + myTables ( "Employees" ).ToString ( ) _
+ ControlChars.Cr + "Index: " + myTables.IndexOf ( "Employees" ).ToString ( ) )
Else
MessageBox.Show ( "Error: no such table in collection" )
End If
End Sub |
|
C# |
VB |
DataTableMappingCollection Members DataTableMappingCollection.Contains Overload List