System.Data Namespace IDataAdapter Class
Returns a collection of table mapping objects, each representing how a source table is mapped to a data set table.
Script |
[ ITableMappingCollection variable = ] IDataAdapter.TableMappings |
An ITableMappingCollection that provides the master mapping between the tables in a data source and the DataTable objects in a DataSet.
This property is read-only with no default value.
The ITableMappingCollection interface allows an inheriting class to implement a table mapping collection. When reconciling changes, the IDataAdapter uses the ITableMappingCollection to associate the column names used by the data source with the column names used by the DataSet.
An application does not create an instance of the ITableMappingCollection interface directly, but creates an instance of a class that inherits ITableMappingCollection.
Classes that inherit ITableMappingCollection must implement the inherited members, and typically define additional members to add provider-specific functionality. For example, the ITableMappingCollection interface defines one implementation of the RemoveAt method. In turn, the DataTableMappingCollection class inherits this method, and defines two additional overloads of RemoveAt.
Notes to Implementers: When you inherit from the ITableMappingCollection interface, you should implement the following constructor:
Item |
Description |
PrvTableMappingCollection ( ) |
Creates an empty PrvTableMappingCollection class. |
For more information, see Setting Up DataTable and DataColumn Mappings.
The following example uses a derived class, OleDbDataAdapter, to add DataTableMapping objects to its TableMappings collection and display a list of those mapped source tables. This example assumes that an OleDbDataAdapter has already been created.
void ShowTableMappings ( ) {
// ... code to construct dataadapter here ...
myAdapter.TableMappings.Add ( "Categories","DataCategories" );
myAdapter.TableMappings.Add ( "Orders","DataOrders" );
myAdapter.TableMappings.Add ( "Products","DataProducts" );
string myMessage = "Table Mappings:\n";
for ( int i=0; i < myAdapter.TableMappings.Count; i++ ) {
myMessage += i.ToString ( ) + " " +
myAdapter.TableMappings [ ].ToString ( ) + "<br>";
}
Response.Write ( myMessage );
}
Public Sub ShowTableMappings ( )
' ... code to construct dataadapter here ...
myAdapter.TableMappings.Add ( "Categories", "DataCategories" )
myAdapter.TableMappings.Add ( "Orders", "DataOrders" )
myAdapter.TableMappings.Add ( "Products", "DataProducts" )
Dim myMessage As String = "Table Mappings:" + ControlChars.Cr
Dim i As Integer
For i = 0 To myAdapter.TableMappings.Count - 1
myMessage = myMessage & i.ToString ( ) & " " & _
myAdapter.TableMappings ( i ).ToString ( ) & ControlChars.Cr
Next i
Response.Write ( myMessage )
End Sub |
|
C# |
VB |
IDataAdapter Members