Export (0) Print
Expand All

DataTableMappingCollection.GetTableMappingBySchemaAction Method

Gets a DataColumnMapping object with the specified source table name and DataSet table name, using the given MissingMappingAction.

[Visual Basic]
Public Shared Function GetTableMappingBySchemaAction( _
   ByVal tableMappings As DataTableMappingCollection, _
   ByVal sourceTable As String, _
   ByVal dataSetTable As String, _
   ByVal mappingAction As MissingMappingAction _
) As DataTableMapping
[C#]
public static DataTableMapping GetTableMappingBySchemaAction(
 DataTableMappingCollection tableMappings,
 string sourceTable,
 string dataSetTable,
 MissingMappingAction mappingAction
);
[C++]
public: static DataTableMapping* GetTableMappingBySchemaAction(
 DataTableMappingCollection* tableMappings,
 String* sourceTable,
 String* dataSetTable,
 MissingMappingAction mappingAction
);
[JScript]
public static function GetTableMappingBySchemaAction(
   tableMappings : DataTableMappingCollection,
 sourceTable : String,
 dataSetTable : String,
 mappingAction : MissingMappingAction
) : DataTableMapping;

Parameters

tableMappings
The DataTableMappingCollection collection to search.
sourceTable
The case-sensitive name of the mapped source table.
dataSetTable
The name, which is not case-sensitive, of the mapped DataSet table.
mappingAction
One of the MissingMappingAction values.

Return Value

A DataTableMapping object.

Exceptions

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

Remarks

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

If the DataTableMapping does not exist in the collection for a given MissingMappingAction, the following happens:

MissingMappingAction Action Taken
Passthrough Creates a DataTableMapping object with the given sourceTable as the source table name and dataSetTable as the DataSet table name. The created DataTableMapping object is not added to the collection.
Error An exception is generated. The dataSetTable parameter is ignored.
Ignore Gets a a null reference (Nothing in Visual Basic) value. The dataSetTable parameter is ignored.

Example

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

[Visual Basic] 
Public Sub FindDataTableMapping()
    ' ...
    ' create myTableMappings and myNewMapping
    ' ...
    If myTableMappings.Contains("Categories") Then
        myNewMapping = _
           DataTableMappingCollection.GetTableMappingBySchemaAction _
           (myTableMappings, "Categories", "", MissingMappingAction.Ignore)
    End If
End Sub

[C#] 
public void FindDataTableMapping() {
   // ...
   // create myTableMappings and myNewMapping
   // ...
   if (myTableMappings.Contains("Categories")) {
      myNewMapping = DataTableMappingCollection.GetTableMappingBySchemaAction
         (myTableMappings, "Categories", "", MissingMappingAction.Ignore);
   }
}

[C++] 
void FindDataTableMapping() {
   // ...
   // create myTableMappings and myNewMapping
   // ...
   if (myTableMappings->Contains(S"Categories")) {
       myNewMapping = DataTableMappingCollection::GetTableMappingBySchemaAction
          (myTableMappings, S"Categories", S"", 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.

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

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

Show:
© 2014 Microsoft