DB2®BulkCopyColumnMapping.SourceColumn Property
Name of the column being copied from the data source.
- Namespace:
IBM.Data.DB2
- Assembly:
IBM.Data.DB2
(inIBM.Data.DB2.dll
)
Syntax
[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);
Property value
The string value of the source column name.
Remarks
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.
For
case sensitivity to be maintained, the column name must be enclosed
within an extra set of double quotation marks. For example, the source
column can be set as follows:
salesCopy.ColumnMappings.SourceColumn= "\"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");
}
}