Mapping Tables and Columns
default, when you use the
DataAdapter to fill a
the column names that are used in the
correspond to the column names defined in the data source.
The data adapter has a collection of table-mapping objects that are
accessed through the
TableMappings property. A
table-mapping object maps a table in the data source to a table with
a different name in the
DataSet. Table mappings
are perhaps most commonly used to map default table names that are
created as a result of filling a
DataSet from a
query that returns multiple result sets. When multiple result sets
are added to a
DataSet using the
Fill( ) method of the
DataAdapter, they are
assigned the default names
Table2, and so on.
Mapping the table names ensures that the data is updated to the
correct tables in the data source. Of course, the table objects can
also be renamed with the same result.
Each table-mapping object has a collection of column-mapping objects
that are accessed through the
property. A column-mapping object maps a column in the data source to
a column with a different name in the
within the table defined by the containing table-mapping object.
Figure 14-3 shows how tables and columns in the
DataSet and data source are mapped to each other
using mapping classes in the
Both table ...