DataAdapter.TableMappings Property
Gets a collection that provides the master mapping between a source table and a DataTable.
[Visual Basic] Public ReadOnly Property TableMappings As _ DataTableMappingCollection [C#] public DataTableMappingCollection TableMappings {get;} [C++] public: __property DataTableMappingCollection* get_TableMappings(); [JScript] public function get TableMappings() : DataTableMappingCollection;
Property Value
A collection that provides the master mapping between the returned records and the DataSet. The default value is an empty collection.
Remarks
When reconciling changes, the DataAdapter uses the DataTableMappingCollection collection to associate the column names used by the data source with the column names used by the DataSet.
Example
[Visual Basic, C#, C++] 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.
[Visual Basic] Public Sub ShowTableMappings() ' ... ' create myDataAdapter ' ... myDataAdapter.TableMappings.Add("Categories", "DataCategories") myDataAdapter.TableMappings.Add("Orders", "DataOrders") myDataAdapter.TableMappings.Add("Products", "DataProducts") Dim myMessage As String = "Table Mappings:" + ControlChars.Cr Dim i As Integer For i = 0 To myDataAdapter.TableMappings.Count - 1 myMessage += i.ToString() + " " _ + myDataAdapter.TableMappings(i).ToString() + ControlChars.Cr Next i MessageBox.Show(myMessage) End Sub [C#] public void ShowTableMappings() { // ... // create myDataAdapter // ... myDataAdapter.TableMappings.Add("Categories","DataCategories"); myDataAdapter.TableMappings.Add("Orders","DataOrders"); myDataAdapter.TableMappings.Add("Products","DataProducts"); string myMessage = "Table Mappings:\n"; for(int i=0;i < myDataAdapter.TableMappings.Count;i++) { myMessage += i.ToString() + " " + myDataAdapter.TableMappings[i].ToString() + "\n"; } MessageBox.Show(myMessage); } [C++] void ShowTableMappings() { // ... // create myDataAdapter // ... myDataAdapter->TableMappings->Add(S"Categories",S"DataCategories"); myDataAdapter->TableMappings->Add(S"Orders",S"DataOrders"); myDataAdapter->TableMappings->Add(S"Products",S"DataProducts"); String* myMessage = S"Table Mappings:\n"; for(int i=0;i < myDataAdapter->TableMappings->Count;i++) { String::Concat( myMessage, __box(i)->ToString(), S" ", myDataAdapter->TableMappings->Item[i]->ToString(), "\n" ); } MessageBox::Show(myMessage); }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
See Also
DataAdapter Class | DataAdapter Members | System.Data.Common Namespace