Export (0) Print
Expand All

DataTableMappingCollection.Add Method

Adds a DataTableMapping object to the collection.

Overload List

Adds an Object that is a table mapping to the collection.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Overridable Function Add(Object) As Integer Implements IList.Add
[C#] public virtual int Add(object);
[C++] public: virtual int Add(Object*);
[JScript] public function Add(Object) : int;

Adds a DataTableMapping object to the collection when given a source table name and a DataSet table name.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Function Add(String, String) As DataTableMapping
[C#] public DataTableMapping Add(string, string);
[C++] public: DataTableMapping* Add(String*, String*);
[JScript] public function Add(String, String) : DataTableMapping;

Example

[Visual Basic, C#, C++] The following example creates a DataTableMappingCollection, adds DataTableMapping objects to the collection, and displays a list of the mapped source tables.

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of Add. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Public Sub CreateTableMappings()
    Dim myTableMappings As New DataTableMappingCollection()
    myTableMappings.Add("Categories", "DataCategories")
    myTableMappings.Add("Orders", "DataOrders")
    myTableMappings.Add("Products", "DataProducts")
    Dim myMessage As String = "TableMappings:" + ControlChars.Cr
    Dim i As Integer
    For i = 0 To myTableMappings.Count - 1
        myMessage += i.ToString() + " " + myTableMappings(i).ToString() _
           + ControlChars.Cr
    Next i
    MessageBox.Show(myMessage)
End Sub

[C#] 
public void CreateTableMappings() {
   DataTableMappingCollection myTableMappings = new DataTableMappingCollection();
   myTableMappings.Add("Categories","DataCategories");
   myTableMappings.Add("Orders","DataOrders");
   myTableMappings.Add("Products","DataProducts");
   string myMessage = "TableMappings:\n";
   for(int i=0;i < myTableMappings.Count;i++)
   {
      myMessage += i.ToString() + " " + myTableMappings[i].ToString() + "\n";
   }
   MessageBox.Show(myMessage);
}

[C++] 
void CreateTableMappings() {
   DataTableMappingCollection* myTableMappings = new DataTableMappingCollection;
   myTableMappings->Add(S"Categories",S"DataCategories");
   myTableMappings->Add(S"Orders",S"DataOrders");
   myTableMappings->Add(S"Products",S"DataProducts");
   String* myMessage = S"TableMappings:\n";
   for(int i=0;i < myTableMappings->Count;i++)
   {
       myMessage = String::Concat( myMessage, __box(i)->ToString(), S" ", myTableMappings->Item[i]->ToString(), S"\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 Language Filter in the upper-left corner of the page.

See Also

DataTableMappingCollection Class | DataTableMappingCollection Members | System.Data.Common Namespace

Show:
© 2014 Microsoft