DB2®BulkCopy.DB2BulkCopy(string) Constructor
Initializes a new instance of the DB2BulkCopy class with a database connection string.
- Namespace:
IBM.Data.DB2- Assembly:
IBM.Data.DB2(inIBM.Data.DB2.dll)
Syntax
[Visual Basic]
Public Sub New(connectionString As String)
[C#]
public DB2BulkCopy(string connectionString);
[C++]
public: DB2BulkCopy(String* connectionString);
[JScript]
public function DB2BulkCopy(connectionString : String);
Parameters
- connectionString
- The connection string for the database connection.
Remarks
A DB2Connection object will be initialized using the connection string information. The DB2Connection will be opened and data will be copied to the table. The DB2Connection will be automatically closed after the bulk copy operation.
Example
[C#] The following example demonstrates a bulk copy of data from a DataTable source into the SALES table.
[C#]
public static void copyIntoSales(String connString, DataTable source)
{
DB2BulkCopy salesCopy = new DB2BulkCopy(connString);
salesCopy.DestinationTableName = "SALES";
try
{
salesCopy.WriteToServer(source);
salesCopy.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Exception");
}
}