DB2®BulkCopyColumnMappingCollection.Add(string, string) Method

Creates a DB2BulkCopyColumnMapping using column names for the data source and destination columns, and adds it to the DB2BulkCopyColumnMappingCollection.

Namespace:
IBM.Data.DB2
Assembly:
IBM.Data.DB2 (in IBM.Data.DB2.dll)

Syntax


[Visual Basic]
Public Function Add ( _
          src As String, _
          dest As String _
) As DB2BulkCopyColumnMapping
[C#]
public DB2BulkCopyColumnMapping Add(
         string src,
         string dest
)
[C++]
public:
DB2BulkCopyColumnMapping* Add (
         String* src,
         String* dest
)
[JScript]
public function Add (
          src : String,
          dest : String
) : DB2BulkCopyColumnMapping

Parameters

src
Name of the column being copied from the data source.
dest
Name of the column being mapped in the destination table.

Return value

The column mapping added to the DB2BulkCopyColumnMappingCollection.

Example

[C#] The following example demonstrates a bulk copy of data from a DB2DataReader into the DEPARTMENT table. The column mappings between the source and target tables are defined by a DB2BulkCopyColumnMappingCollection instance.

[C#]
public static void copyIntoSales(DB2Connection conn, DB2DataReader reader)
{
  DB2BulkCopy salesCopy = new DB2BulkCopy(conn);
  salesCopy.DestinationTableName = "DEPARTMENT";

  DB2BulkCopyColumnMappingCollection colMapCollection;
  colMapCollection = new DB2BulkCopyColumnMappingCollection();

  salesCopy.ColumnMappings = colMapCollection;

  colMapCollection.Add("DEPTNUMB", "DEPTNO");
  colMapCollection.Add("DEPTNAME", "DEPTNAME");
  colMapCollection.Add("MANAGER", "ADMRDEPT");
  colMapCollection.Add("LOCATION", "LOCATION");

  try
  {
    salesCopy.WriteToServer(reader);
    salesCopy.Close();
  }
  catch (DB2Exception ex)
  {
    MessageBox.Show(ex.ToString(), "Exception");
  }
}