DataColumnMappingCollection.GetColumnMappingBySchemaAction Method

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

Namespace: System.Data.Common
Assembly: System.Data (in

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
Not applicable.



The DataColumnMappingCollection.


The case-sensitive source column name to find.


One of the MissingMappingAction values.

Return Value

A DataColumnMapping object.

Exception typeCondition


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:


Action Taken


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.


An InvalidOperationException is generated if the specified column mapping is missing.


Gets a null value.

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.

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

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions