Name of the column being copied from the data source.
[Visual Basic]
Public Property SourceColumn As String
[C#]
public string SourceColumn {get; set;}
[C++]
public: __property String* get_SourceColumn();
public: __property void set_SourceColumn(String*);
[JScript]
public function get SourceColumn() : String;
public function set SourceColumn(String);
The string value of the source column name.
In the case where a source column value is set multiple times (if values are added multiple times to either the SourceColumn or SourceOrdinal 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.
salesCopy.ColumnMappings.SourceColumn= "\"LoCaTion\"";
[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");
}
}