DB2®BulkCopyColumnMapping.DestinationColumn Property
Name of the column being mapped in the destination table.
- Namespace:
IBM.Data.DB2
- Assembly:
IBM.Data.DB2
(inIBM.Data.DB2.dll
)
Syntax
[Visual Basic]
Public Property DestinationColumn As String
[C#]
public string DestinationColumn {get; set;}
[C++]
public: __property String* get_DestinationColumn();
public: __property void set_DestinationColumn(String*);
[JScript]
public function get DestinationColumn() : String;
public function set DestinationColumn(String);
Property value
The string value of the destination column name.
Remarks
In the case where a destination column value is set multiple times (if values are added multiple times to either the DestinationColumn or DestinationOrdinal properties, or if a value is assigned at least once in each of these two properties), the last value set is what is used in the Add method.
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:
salesCopy.ColumnMappings.DestinationColumn= "\"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 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");
}
}