DB2®BulkCopyColumnMapping.DB2BulkCopyColumnMapping(string, string) Constructor
Initializes a new DB2BulkCopyColumnMapping object using column names for the data source and destination columns.
- Namespace:
IBM.Data.DB2
- Assembly:
IBM.Data.DB2
(inIBM.Data.DB2.dll
)
Syntax
[Visual Basic]
Public Sub New ( _
source As String, _
destination As String _
)
[C#]
public DB2BulkCopyColumnMapping(
string source
string destination
);
[C++]
public: DB2BulkCopyColumnMapping(
String* source
String* destination
);
[JScript]
public function DB2BulkCopyColumnMapping(
source : String,
destination : String
)
Parameters
- source
- Name 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 source and destination columns can be set as follows:
DB2BulkCopyColumnMapping colMapDeptNum =
new DB2BulkCopyColumnMapping("\"LoCaTion1\"", "\"LoCaTion2\"");
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("\"DEPTNUMB\"", "\"DEPTNO\"");
DB2BulkCopyColumnMapping colMapDeptNme =
new DB2BulkCopyColumnMapping("\"DEPTNAME\"", "\"DEPTNAME\"");
DB2BulkCopyColumnMapping colMapDeptMgr =
new DB2BulkCopyColumnMapping("\"MANAGER\"", "\"ADMRDEPT\"");
DB2BulkCopyColumnMapping colMapDeptLoc =
new DB2BulkCopyColumnMapping("\"LOCATION\"", "\"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");
}
}