DB2®BulkCopyColumnMapping.SourceOrdinal Property
Ordinal value 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 SourceOrdinal As Integer
[C#]
public int SourceOrdinal {get; set;}
[C++]
public: __property int get_SourceOrdinal();
public: __property void set_SourceOrdinal(int);
[JScript]
public function get SourceOrdinal() : int;
public function set SourceOrdinal(int);
Property value
The integer value of the ordinal representing the source column.
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.
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 SourceOrdinal and DestinationOrdinal 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.DestinationOrdinal = 0;
colMapDeptNme.DestinationOrdinal = 1;
colMapDeptMgr.DestinationOrdinal = 3;
colMapDeptLoc.DestinationOrdinal = 4;
colMapDeptNum.SourceOrdinal = 0;
colMapDeptNme.SourceOrdinal = 1;
colMapDeptMgr.SourceOrdinal = 2;
colMapDeptLoc.SourceOrdinal = 4;
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");
}
}