System.Data.Common Namespace DataTableMapping Class
Returns the collection of column mappings for a table.
Script |
[ DataColumnMappingCollection variable = ] DataTableMapping.ColumnMappings |
A DataColumnMappingCollection that provides the mappings between fields in a data source and DataColumn objects in a DataSet.
The property is read only with no default value.
The ColumnMappings property is used to retrieve the collection of DataColumnMapping objects, each of which represents the mapping between a field in a table in the data source and a linked DataColumn in a DataTable within a DataSet.
The column mappings for a data table are not exposed directly, but are accessed via a DataTableMapping object, which in turn is exposed via the TableMappings property of a given DataAdapter.
The following example demonstrates using the ColumnMappings property to print the values of each DataColumnMapping object in the collection.
void getColumnMappings ( DataTableMapping myTableMap ) {
// get column mappings
DataColumnMappingCollection myFieldsMaps = myTableMap.ColumnMappings;
string myMessage = "Column Mappings:\n";
for ( int i=0; i < myFieldsMaps.Count; i++ ) {
myMessage += i.ToString ( ) + " " + myFieldsMaps [ ].ToString ( ) + "\n";
}
Response.Write ( myMessage );
}
Public Sub getColumnMappings ( ByVal myTableMap As DataTableMapping )
' get column mappings
Dim myFieldsMaps As DataColumnMappingCollection = myTableMap.ColumnMappings
Dim myMessage As String = "Column Mappings:" + ControlChars.Cr
Dim i As Integer
For i = 0 To myFieldsMaps.Count - 1
myMessage += i.ToString ( ) + " " + myFieldsMaps ( i ).ToString ( ) + ControlChars.Cr
Next i
Response.Write ( myMessage )
End Sub |
|
C# |
VB |
DataTableMapping Members