System.Data.Common Namespace
Represents the mapping between a field in a data source and its linked DataColumn in a DataSet.
A DataColumnMapping provides a mapping between a field in a table in the data source, and a DataColumn in a DataTable that contains the results of the query issued against the data source. This class is used by a DataAdapter when populating a DataSet.
A DataColumnMapping enables you to use column names in a DataTable that are different from those in the data source. The DataAdapter uses the mapping to match the columns when the tables in the DataSet or data source are updated.
For more information, see Setting Up DataTable and DataColumn Mappings.
The following example initializes a DataColumnMapping object and adds it to a DataColumnMappingCollection.
void AddDataColumnMapping ( DataTableMapping myTableMap ) {
// get column mappings
DataColumnMappingCollection myFieldsMaps = myTableMap.ColumnMappings;
DataColumnMapping myMap = new DataColumnMapping ( "Description", "DataDescription" );
myFieldsMaps.Add ( ( Object ) myMap );
Response.Write ( "column " + myMap.ToString ( ) + " added to " +
"column mapping collection " + myFieldsMaps.ToString ( ) );
}
Public Sub AddDataColumnMapping ( ByVal myTableMap As DataTableMapping )
' get column mappings
Dim myFieldsMaps As DataColumnMappingCollection = myTableMap.ColumnMappings
Dim myMap As New DataColumnMapping ( "Description", "DataDescription" )
myFieldsMaps.Add ( CType ( myMap, Object ) )
Response.Write ( "column " + myMap.ToString ( ) + " added to " _
+ "column mapping collection " + myFieldsMaps.ToString ( ) )
End Sub |
|
C# |
VB |
DataColumnMappingCollection DataTableMapping DataTableMappingCollection