This documentation is archived and is not being maintained.

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;


[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
End Sub


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

void CreateColumnMappings() {
   DataColumnMappingCollection* myColumnMappings = new DataColumnMappingCollection;
   myColumnMappings->Add(S"Category Name",S"DataCategory");
   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" );

[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