Export (0) Print
Expand All

IColumnMappingCollection.IndexOf Method

Gets the location of the DataColumnMapping object with the specified source column name. The name is case-sensitive.

[Visual Basic]
Function IndexOf( _
   ByVal sourceColumnName As String _
) As Integer
[C#]
int IndexOf(
   string sourceColumnName
);
[C++]
int IndexOf(
   String* sourceColumnName
);
[JScript]
function IndexOf(
   sourceColumnName : String
) : int;

Parameters

sourceColumnName
The case-sensitive name of the source column.

Return Value

The zero-based location of the DataColumnMapping object with the specified source column name.

Example

[Visual Basic, C#, C++] The following example searches for an instance of the derived class, DataColumnMapping, with the given source column name within a DataColumnMappingCollection collection. If the DataColumnMapping exists, the example displays the name and the index of the mapping. If the mapping does not exist, the example displays an error. This example assumes that a DataColumnMappingCollection collection has been created.

[Visual Basic] 
Public Sub FindDataColumnMapping()
    ' ...
    ' create myColumnMappings
    ' ...
    If Not myColumnMappings.Contains("Description") Then
        MessageBox.Show("Error: no such table in collection")
    Else
        MessageBox.Show("Name: " + myColumnMappings("Description").ToString() _
           + ControlChars.Cr + "Index: " _
           + myColumnMappings.IndexOf("Description").ToString())
    End If
End Sub

[C#] 
public void FindDataColumnMapping() {
   // ...
   // create myColumnMappings
   // ...
   if (!myColumnMappings.Contains("Description"))
      MessageBox.Show("Error: no such table in collection");
   else
      MessageBox.Show("Name: " + myColumnMappings["Description"].ToString()
         + "\nIndex: " + myColumnMappings.IndexOf("Description").ToString());
}

[C++] 
void FindDataColumnMapping() {
   // ...
   // create myColumnMappings
   // ...
   if (!myColumnMappings->Contains("Description"))
       MessageBox::Show(S"Error: no such table in collection");
   else
       MessageBox::Show(String::Concat( S"Name: ", myColumnMappings->Item[S"Description"]->ToString(), S"\nIndex: ", __box(myColumnMappings->IndexOf(S"Description"))->ToString() ));
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

IColumnMappingCollection Interface | IColumnMappingCollection Members | System.Data Namespace

Show:
© 2014 Microsoft