asp.net.ph

DataTableMappingCollection.IndexOf Method ( String )

System.Data.Common Namespace   DataTableMappingCollection Class


Returns the index of a DataTableMapping with the specified SourceTable name.

[ VB ]
NotOverridable Overloads Public Function IndexOf ( _
   ByVal sourceTable As String _
) As Integer Implements ITableMappingCollection.IndexOf

[ C# ]
public int IndexOf (
   String sourceTable
);

[ C++ ]
public: __sealed int IndexOf (
   String* sourceTable
);

[ JScript ]
public function IndexOf (
   sourceTable : String
) : int

Parameters

sourceTable
The case-sensitive name of a SourceTable.

Return Value

The index of the DataTableMapping if it is in the collection; otherwise, -1.

Implements

ITableMappingCollection.IndexOf

Remarks

Use the IndexOf method to determine the index of a given table mapping object.

Before calling IndexOf, you can test for the existence of a table mapping by using the Contains method.

Example

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

See Also

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