DB2®BulkCopyColumnMappingCollection.Add(int, string) Method

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

Parameters

src
Ordinal value 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(0, "DEPTNO");
  colMapCollection.Add(1, "DEPTNAME");
  colMapCollection.Add(2, "ADMRDEPT");
  colMapCollection.Add(4, "LOCATION");

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