DB2®BulkCopy.DB2BulkCopy(IBM®.Data.DB2.DB2Connection, IBM.Data.DB2.DB2BulkCopyOptions) Constructor
Initializes a new instance of the DB2BulkCopy class with a DB2Connection object and DB2BulkCopyOptions enumeration values.
- Namespace:
IBM.Data.DB2
- Assembly:
IBM.Data.DB2
(inIBM.Data.DB2.dll
)
Syntax
[Visual Basic]
Public Sub New( _
connection As DB2Connection, _
options As DB2BulkCopyOptions _
)
[C#]
public DB2BulkCopy(
DB2Connection connection,
DB2BulkCopyOptions options,
);
[C++]
public: DB2BulkCopy(
DB2Connection* connection,
DB2BulkCopyOptions options,
);
[JScript]
public function DB2BulkCopy(
connection : DB2Connection,
options : DB2BulkCopyOptions
);
Parameters
- connection
- A DB2Connection object that represents a connection to a database.
- options
- Options to use during the bulk copy operation. This can be specified as an individual DB2BulkCopyOptions enumeration or a bitwise mask value indicating the desired options from the DB2BulkCopyOptions enumeration.
Remarks
Data will be copied to a table on the data server identified in the connection parameter.
Example
[C#] The following example demonstrates a bulk copy of data from a DataTable source into the SALES table, using the TableLock and Truncate values from the DB2BulkCopyOptions enumeration. All values in the target table will be cleared before the bulk copy operation begins, and the table will be locked during the bulk copy operation.
[C#]
public static void copyIntoSales(DB2Connection conn, DataTable source)
{
DB2BulkCopy salesCopy = new DB2BulkCopy(connString,
(DB2BulkCopyOptions)DB2BulkCopyOptions.TableLock |
DB2BulkCopyOptions.Truncate);
salesCopy.DestinationTableName = "SALES";
try
{
salesCopy.WriteToServer(source);
salesCopy.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Exception");
}
}