System.Data.Common Namespace DataTableMappingCollection Class
Sets or retrieves the DataTableMapping from the collection with the specified source table name.
DataTableMapping variable = DataTableMappingCollection.Item [ sourceTable ];
... or ...
DataTableMapping variable = DataTableMappingCollection [ sourceTable ];
dim variable as DataTableMapping = DataTableMappingCollection.Item ( sourceTable )
... or ...
dim variable as DataTableMapping = DataTableMappingCollection ( sourceTable )
variable : DataTableMapping = DataTableMappingCollection.Item ( sourceTable );
... or ...
variable : DataTableMapping = DataTableMappingCollection ( sourceTable ); |
|
C# |
VB |
JScript |
- sourceTable
- The case-sensitive name of a SourceTable.
The DataTableMapping with the specified name; otherwise a null value if the DataTableMapping does not exist.
Use the Contains method to test for the existence of a specific DataTableMapping.
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" );
}
}
Public Sub FindDataTableMapping ( ByVal myAdapter As DataAdapter )
' get table mappings
Dim myTables As DataTableMappingCollection = myAdapter.TableMappings;
If myTables.Contains ( "Employees" ) Then
MessageBox.Show ( "Name: " + myTables ( "Employees" ).ToString ( ) _
+ ControlChars.Cr + "Index: " + myTables.IndexOf ( "Employees" ).ToString ( ) )
Else
MessageBox.Show ( "Error: no such table in collection" )
End If
End Sub |
|
C# |
VB |
DataTableMappingCollection Members DataTableMappingCollection.Item Overload List