DB2®BulkCopyColumnMappingCollection.Contains Method
Returns a value indicating if the specified DB2BulkCopyColumnMapping object is in the DB2BulkCopyColumnMappingCollection.
- Namespace:
IBM.Data.DB2
- Assembly:
IBM.Data.DB2
(inIBM.Data.DB2.dll
)
Syntax
[Visual Basic]
Public Function Contains ( _
inValue As DB2BulkCopyColumnMapping _
) As Boolean
[C#]
public bool Contains(DB2BulkCopyColumnMapping inValue)
[C++]
public:
bool Contains (DB2BulkCopyColumnMapping* inValue)
[JScript]
public function Contains (
inValue : DB2BulkCopyColumnMapping
) : boolean
Parameters
- inValue
- A DB2BulkCopyColumnMapping object.
Return value
If the specified DB2BulkCopyColumnMapping exists in the
collection, Contains returns true
.
If not, Contains returns false
.
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. In addition to the bulk copy operation, the Contains method is demonstrated as it determines if a DB2BulkCopyColumnMapping exists in the collection.
[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("DEPTNUMB", "DEPTNO");
colMapCollection.Add("DEPTNAME", "DEPTNAME");
colMapCollection.Add("MANAGER", "ADMRDEPT");
colMapCollection.Add("LOCATION", "LOCATION");
//Determine if a DB2BulkCopyColumnMapping
//is included in the current collection.
DB2BulkCopyColumnMapping colMapDeptNum =
new DB2BulkCopyColumnMapping("DEPTNUMB", "DEPTNO");
//If the DB2BulkCopyColumnMapping does exist, print a message indicating this.
if (colMapCollection.Contains(colMapDeptNum))
{
MessageBox.Show(
"The Department Number mapping is included in the mapping collection.");
}
try
{
salesCopy.WriteToServer(reader);
salesCopy.Close();
}
catch (DB2Exception ex)
{
MessageBox.Show(ex.ToString(), "Exception");
}
}