asp.net.ph

DataColumnMappingCollection.Contains Method ( String )

System.Data.Common Namespace   DataColumnMappingCollection Class


Checks whether a DataColumnMapping with the given source column name exists in the collection.

[ VB ]
NotOverridable Overloads Public Function Contains ( _
   ByVal sourceColumn ( ) As String _
) As Boolean Implements IColumnMappingCollection.Contains

[ C# ]
public bool Contains (
   string sourceColumn
);

[ C++ ]
public: __sealed bool Contains (
   String* sourceColumn
);

[ JScript ]
public function Contains (
   sourceColumn : String
) : Boolean

Parameters

sourceColumn
The case-sensitive name of a SourceColumn to find.

Return Value

This method returns only a boolean value: true if the collection contains a DataColumnMapping with the specified source column name; otherwise, false.

Implements

IColumnMappingCollection.Contains

Remarks

Use the Contains method to confirm the existence of a column mapping object before performing further operations on the object.

Example

The following example searches for a DataColumnMapping object with the given source column name within a DataColumnMappingCollection. If the DataColumnMapping exists, the code displays the name and index of the mapping; otherwise, it displays an error.

public void FindDataColumnMapping ( DataTableMapping myTableMap ) {
   // get column mappings
   DataColumnMappingCollection myFieldsMaps = myTableMap.ColumnMappings;
   if ( myFieldsMaps.Contains ( "Description" ) ) {
      MessageBox.Show ( "Name: " + myFieldsMaps [ "Description" ].ToString ( )
         + "\nIndex: " + myFieldsMaps.IndexOf ( "Description" ).ToString ( ) );
   } else {
      MessageBox.Show ( "Error: no such field in collection" );
   }
}
  C# VB

See Also

DataColumnMappingCollection Members   DataColumnMappingCollection.Contains Overload List 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