DB2®BulkCopy.DB2BulkCopy(IBM®.Data.DB2.DB2Connection) Constructor
Initializes a new instance of the DB2BulkCopy class with a DB2Connection object.
- Namespace:
IBM.Data.DB2
- Assembly:
IBM.Data.DB2
(inIBM.Data.DB2.dll
)
Syntax
[Visual Basic]
Public Sub New(connection As DB2Connection)
[C#]
public DB2BulkCopy(DB2Connection connection);
[C++]
public: DB2BulkCopy(DB2Connection* connection);
[JScript]
public function DB2BulkCopy(connection : DB2Connection);
Parameters
- connection
- A DB2Connection object that represents a connection to a database.
Exceptions
Exception type | Condition |
---|---|
InvalidOperationException | This DB2BulkCopy constructor requires access to an open database connection. |
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.
[C#]
public static void copyIntoSales(DB2Connection conn, DataTable source)
{
DB2BulkCopy salesCopy = new DB2BulkCopy(conn);
salesCopy.DestinationTableName = "SALES";
try
{
salesCopy.WriteToServer(source);
salesCopy.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Exception");
}
}