SqlBulkCopy Constructor (SqlConnection, SqlBulkCopyOptions, SqlTransaction)
Initializes a new instance of the SqlBulkCopy class using the supplied existing open instance of SqlConnection. The SqlBulkCopy instance behaves according to options supplied in the copyOptions parameter. If a non-null SqlTransaction is supplied, the copy operations will be performed within that transaction.
Assembly: System.Data (in System.Data.dll)
public SqlBulkCopy( SqlConnection connection, SqlBulkCopyOptions copyOptions, SqlTransaction externalTransaction )
- Type: System.Data.SqlClient.SqlConnection
The already open SqlConnection instance that will be used to perform the bulk copy. If your connection string does not use Integrated Security = true, you can use SqlCredential to pass the user ID and password more securely than by specifying the user ID and password as text in the connection string.
- Type: System.Data.SqlClient.SqlBulkCopyOptions
A combination of values from the SqlBulkCopyOptions enumeration that determines which data source rows are copied to the destination table.
If options include UseInternalTransaction and the externalTransaction argument is not null, an InvalidArgumentException is thrown.
For examples demonstrating how to use SqlBulkCopy in a transaction, see Transaction and Bulk Copy Operations.