DB2®BulkCopyColumnMapping.DB2BulkCopyColumnMapping() Constructor
Default constructor that initializes a new DB2BulkCopyColumnMapping object.
- Namespace:
IBM.Data.DB2- Assembly:
IBM.Data.DB2(inIBM.Data.DB2.dll)
Syntax
[Visual Basic]
Public Sub New
[C#]
public DB2BulkCopyColumnMapping();
[C++]
public: DB2BulkCopyColumnMapping();
[JScript]
public function DB2BulkCopyColumnMapping();
Remarks
If you use this constructor to create a DB2BulkCopyColumnMapping instance, you will need to assign source and destination columns. Source columns can be defined by the SourceColumn and SourceOrdinal properties. Destination columns can be defined by the DestinationColumn and DestinationOrdinal properties.
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 by SourceColumn and DestinationColumn properties.
[C#]
public static void copyIntoSales(DB2Connection conn, DB2DataReader reader)
{
DB2BulkCopy salesCopy = new DB2BulkCopy(conn);
salesCopy.DestinationTableName = "DEPARTMENT";
DB2BulkCopyColumnMapping colMapDeptNum = new DB2BulkCopyColumnMapping();
DB2BulkCopyColumnMapping colMapDeptNme = new DB2BulkCopyColumnMapping();
DB2BulkCopyColumnMapping colMapDeptMgr = new DB2BulkCopyColumnMapping();
DB2BulkCopyColumnMapping colMapDeptLoc = new DB2BulkCopyColumnMapping();
colMapDeptNum.DestinationColumn = "DEPTNO";
colMapDeptNme.DestinationColumn = "DEPTNAME";
colMapDeptMgr.DestinationColumn = "ADMRDEPT";
colMapDeptLoc.DestinationColumn = "LOCATION";
colMapDeptNum.SourceColumn = "DEPTNUMB";
colMapDeptNme.SourceColumn = "DEPTNAME";
colMapDeptMgr.SourceColumn = "MANAGER";
colMapDeptLoc.SourceColumn = "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");
}
}