Export (0) Print
Expand All

DataColumnMappingCollection.GetColumnMappingBySchemaAction Method

Gets a DataColumnMapping for the specified DataColumnMappingCollection, source column name, and MissingMappingAction.

[Visual Basic]
Public Shared Function GetColumnMappingBySchemaAction( _
   ByVal columnMappings As DataColumnMappingCollection, _
   ByVal sourceColumn As String, _
   ByVal mappingAction As MissingMappingAction _
) As DataColumnMapping
public static DataColumnMapping GetColumnMappingBySchemaAction(
 DataColumnMappingCollection columnMappings,
 string sourceColumn,
 MissingMappingAction mappingAction
public: static DataColumnMapping* GetColumnMappingBySchemaAction(
 DataColumnMappingCollection* columnMappings,
 String* sourceColumn,
 MissingMappingAction mappingAction
public static function GetColumnMappingBySchemaAction(
   columnMappings : DataColumnMappingCollection,
 sourceColumn : String,
 mappingAction : MissingMappingAction
) : DataColumnMapping;


the DataColumnMappingCollection.
The case-sensitive source column name to find.
One of the MissingMappingAction values.

Return Value

A DataColumnMapping object.


Exception Type Condition
InvalidOperationException The mappingAction parameter was set to Error, and no mapping was specified.


If the DataColumnMapping exists in the collection, it is returned.

If the DataColumnMapping does not exist in the collection, for a given MissingMappingAction, the following actions occur:

MissingMappingAction Action Taken
Passthrough Creates a DataColumnMapping with the specified source column name as both the source column name and the DataSet column name. This DataColumnMapping is not added to the collection.
Error An InvalidOperationException is generated if the specified column mapping is missing.
Ignore Gets a null value.


[Visual Basic, C#, C++] The following example searches for a DataColumnMapping with the given source column name within the collection. If the object exists, it is returned. The example assumes that a DataColumnMappingCollection collection and a DataColumnMapping object have been created.

[Visual Basic] 
Public Sub FindDataColumnMapping()
    ' ...
    ' create myColumnMappings and myNewMapping
    ' ...
    If myColumnMappings.Contains("Description") Then
        myNewMapping = _
           DataColumnMappingCollection.GetColumnMappingBySchemaAction _
           (myColumnMappings, "Description", MissingMappingAction.Ignore)
    End If
End Sub

public void FindDataColumnMapping() {
   // ...
   // create myColumnMappings and myNewMapping
   // ...
   if (myColumnMappings.Contains("Description"))
      myNewMapping = DataColumnMappingCollection.GetColumnMappingBySchemaAction
         (myColumnMappings, "Description", MissingMappingAction.Ignore);

void FindDataColumnMapping() {
   // ...
   // create myColumnMappings and myNewMapping
   // ...
   if (myColumnMappings->Contains(S"Description"))
       myNewMapping = DataColumnMappingCollection::GetColumnMappingBySchemaAction
       (myColumnMappings, S"Description", MissingMappingAction::Ignore);

[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.


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

DataColumnMappingCollection Class | DataColumnMappingCollection Members | System.Data.Common Namespace

© 2015 Microsoft