DataTableMappingCollection.Add Method (String, String)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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

Namespace:   System.Data.Common
Assembly:  System.Data (in System.Data.dll)

public DataTableMapping Add(
	string sourceTable,
	string dataSetTable
)

Parameters

sourceTable
Type: System.String

The case-sensitive name of the source table to map from.

dataSetTable
Type: System.String

The name, which is not case-sensitive, of the DataSet table to map to.

Return Value

Type: System.Data.Common.DataTableMapping

The DataTableMapping object that was added to the collection.

The following example creates a DataTableMappingCollection, adds DataTableMapping objects to the collection, and displays a list of the mapped source tables.

public void CreateTableMappings() 
{
    DataTableMappingCollection mappings = 
        new DataTableMappingCollection();
    mappings.Add("Categories","DataCategories");
    mappings.Add("Orders","DataOrders");
    mappings.Add("Products","DataProducts");
    string message = "TableMappings:\n";
    for(int i=0;i < mappings.Count;i++)
    {
        message += i.ToString() + " " 
            + mappings[i].ToString() + "\n";
    }
    Console.WriteLine(message);
}

.NET Framework
Available since 1.1
Return to top
Show: