System.Data.Common Namespace
Represents a collection of DataTableMapping objects for a DataAdapter.
The DataTableMappingCollection contains the collection of DataTableMapping objects that link the tables in a DataSet to those in a data source. This collection is accessed via the DataAdapter.TableMappings property.
Like most data collections in ADO.NET, the DataTableMappingCollection uses standard collection methods to manage the items in the collection. These include the methods Add, Clear, and Remove.
The collection also includes a Count property to determine how many DataColumn objects are in the collection, and a Contains method to verify whether a specified column mapping exists in the collection.
The following example demonstrates using the TableMappings property to print the values of each DataTableMapping object in the collection.
void getTableMappings ( DataAdapter myAdapter ) {
// get table mappings
DataTableMappingCollection myTables = myAdapter.TableMappings;
string myMessage = "Table Mappings:\n";
for ( int i=0; i < myTables.Count; i++ ) {
myMessage += i.ToString ( ) + " " + myTables [ ].ToString ( ) + "\n";
}
Response.Write ( myMessage );
}
Public Sub getTableMappings ( ByVal myAdapter As DataAdapter )
' get table mappings
Dim myTables As DataTableMappingCollection = myAdapter.TableMappings
Dim myMessage As String = "Table Mappings:" + ControlChars.Cr
Dim i As Integer
For i = 0 To myTables.Count - 1
myMessage += i.ToString ( ) + " " + myTables ( i ).ToString ( ) + ControlChars.Cr
Next i
Response.Write ( myMessage )
End Sub |
|
C# |
VB |
TableMappings DataTableMapping