DB2®BulkCopyColumnMappingCollection.Add(int, int) Method
Creates a DB2BulkCopyColumnMapping using column ordinals for the data source and destination columns, and adds it to the DB2BulkCopyColumnMappingCollection.
- Namespace:
IBM.Data.DB2- Assembly:
IBM.Data.DB2(inIBM.Data.DB2.dll)
Syntax
[Visual Basic]
Public Function Add ( _
src As Integer, _
dest As Integer _
) As DB2BulkCopyColumnMapping
[C#]
public DB2BulkCopyColumnMapping Add(
int src,
int dest
)
[C++]
public:
DB2BulkCopyColumnMapping* Add (
int src,
int dest
)
[JScript]
public function Add (
src : int,
dest : int
) : DB2BulkCopyColumnMapping
Parameters
- src
- Ordinal value of the column being copied from the data source.
- dest
- Ordinal value of the column being mapped in the destination table.
Return value
The column mapping added to the DB2BulkCopyColumnMappingCollection.
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 by a DB2BulkCopyColumnMappingCollection instance.
[C#]
public static void copyIntoSales(DB2Connection conn, DB2DataReader reader)
{
DB2BulkCopy salesCopy = new DB2BulkCopy(conn);
salesCopy.DestinationTableName = "DEPARTMENT";
DB2BulkCopyColumnMappingCollection colMapCollection;
colMapCollection = new DB2BulkCopyColumnMappingCollection();
salesCopy.ColumnMappings = colMapCollection;
colMapCollection.Add(0, 0);
colMapCollection.Add(1, 1);
colMapCollection.Add(2, 3);
colMapCollection.Add(4, 4);
try
{
salesCopy.WriteToServer(reader);
salesCopy.Close();
}
catch (DB2Exception ex)
{
MessageBox.Show(ex.ToString(), "Exception");
}
}