DB2®BulkCopyColumnMappingCollection Constructor

Initializes a new DB2BulkCopyColumnMappingCollection object.

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

Syntax


[Visual Basic]
Public Sub New
[C#]
public DB2BulkCopyColumnMappingCollection();
[C++]
public: DB2BulkCopyColumnMappingCollection();
[JScript]
public function DB2BulkCopyColumnMappingCollection();

Remarks

If you use this constructor to create a DB2BulkCopyColumnMappingCollection instance, you will need to add column mappings. Column mappings can be added by using the Add methods, or the Insert method.

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");
  }
}