Facilitates the copying of rows from a data source to a table in a database.
System.Object
System.MarshalByRefObject
IBM.Data.DB2.DB2BulkCopy
[Visual Basic]
NotInheritable Public Class DB2BulkCopy
[C#]
public sealed class DB2BulkCopy
[C++]
public ref class DB2BulkCopy sealed
[JScript]
public final class DB2BulkCopy
The source of the data can be DataRow, DataTable, or DataReader objects, which means that data to be copied can come from any source that is readable by your application. A value is generated automatically for such source of data using the GENERATED ALWAYS AS statement.The destination is a table in a database.
To enable the copying of data from columns that have names different from the destination table, DB2BulkCopy uses DB2CopyColumnMapping and DB2CopyColumnMappingCollection objects.
[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");
}
}
Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.