DB2®BulkCopyColumnMapping.DB2BulkCopyColumnMapping(int, string) Constructor

Initializes a new DB2BulkCopyColumnMapping object using a column ordinal for the data source column and a column name for the destination column.

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

Syntax


[Visual Basic]
Public Sub New ( _
  source As Integer, _
  destination As String _
)
[C#]
public DB2BulkCopyColumnMapping(
  int source
  string destination
);
[C++]
public: DB2BulkCopyColumnMapping(
  int source
  String* destination
);
[JScript]
public function DB2BulkCopyColumnMapping(
  source : int,
  destination : String
)

Parameters

source
Ordinal value of the column being copied from the data source.
destination
Name of the column being mapped in the destination table.

Remarks

For case sensitivity to be maintained, the column name must be enclosed within an extra set of double-quotes. For example, the destination column can be set as follows:

DB2BulkCopyColumnMapping colMapDeptNum = 
new DB2BulkCopyColumnMapping(0, "\"LoCaTion\"");

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 in DB2BulkCopyColumnMapping instances.

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

  DB2BulkCopyColumnMapping colMapDeptNum = 
  new DB2BulkCopyColumnMapping(0, "\"DEPTNO\"");
  DB2BulkCopyColumnMapping colMapDeptNme = 
  new DB2BulkCopyColumnMapping(1, "\"DEPTNAME\"");
  DB2BulkCopyColumnMapping colMapDeptMgr = 
  new DB2BulkCopyColumnMapping(2, "\"ADMRDEPT\"");
  DB2BulkCopyColumnMapping colMapDeptLoc = 
  new DB2BulkCopyColumnMapping(4, "\"LOCATION\"");

  salesCopy.ColumnMappings.Add(colMapDeptNum);
  salesCopy.ColumnMappings.Add(colMapDeptNme);
  salesCopy.ColumnMappings.Add(colMapDeptMgr);
  salesCopy.ColumnMappings.Add(colMapDeptLoc);

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