Export (0) Print
Expand All

DataColumnMappingCollection.Add Method

Adds a DataColumnMapping object to the collection.

Overload List

Adds a DataColumnMapping object 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 DataColumnMapping object to the collection when given a source column name and a DataSet column name.

Supported by the .NET Compact Framework.

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

Example

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

[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 CreateColumnMappings()
    Dim myColumnMappings As New DataColumnMappingCollection()
    myColumnMappings.Add("Category Name", "DataCategory")
    myColumnMappings.Add("Description", "DataDescription")
    myColumnMappings.Add("Picture", "DataPicture")
    Dim myMessage As String = "ColumnMappings:" + ControlChars.Cr
    Dim i As Integer
    For i = 0 To myColumnMappings.Count - 1
        myMessage += i.ToString() + " " + myColumnMappings(i).ToString() _
           + ControlChars.Cr
    Next i
    MessageBox.Show(myMessage)
End Sub

[C#] 

 public void CreateColumnMappings() {
    DataColumnMappingCollection myColumnMappings =
       new DataColumnMappingCollection();
    myColumnMappings.Add("Category Name","DataCategory");
    myColumnMappings.Add("Description","DataDescription");
    myColumnMappings.Add("Picture","DataPicture");
    string myMessage = "ColumnMappings:\n";
    for(int i=0;i < myColumnMappings.Count;i++)
    {
       myMessage += i.ToString() + " " + myColumnMappings[i].ToString() + "\n";
    }
    MessageBox.Show(myMessage);
 }

[C++] 
void CreateColumnMappings() {
   DataColumnMappingCollection* myColumnMappings = new DataColumnMappingCollection;
   myColumnMappings->Add(S"Category Name",S"DataCategory");
   myColumnMappings->Add(S"Description",S"DataDescription");
   myColumnMappings->Add(S"Picture",S"DataPicture");
   String* myMessage = S"ColumnMappings:\n";
   for(int i=0;i < myColumnMappings->Count;i++)
   {
       String::Concat( myMessage, __box(i)->ToString(), S" ", myColumnMappings->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

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

Show:
© 2015 Microsoft