DB2®BulkCopyColumnMappingCollection.Add(string, int) Method

Creates a DB2BulkCopyColumnMapping using a column name for the data source column and a column ordinal for the destination column, 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 Integer _
) As DB2BulkCopyColumnMapping
[C#]
public DB2BulkCopyColumnMapping Add(
         string src,
         int dest
)
[C++]
public:
DB2BulkCopyColumnMapping* Add (
         String* src,
         int dest
)
[JScript]
public function Add (
          src : String,
          dest : int
) : DB2BulkCopyColumnMapping

Parameters

src
Name of the column being copied from the data source.
dest
Ordinal value 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", 0);
  colMapCollection.Add("DEPTNAME", 1);
  colMapCollection.Add("MANAGER", 3);
  colMapCollection.Add("LOCATION", 4);

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