Export (0) Print
Expand All

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.

Namespace:  System.Data.SqlClient
Assembly:  System.Data (in System.Data.dll)

new : 
        connection:SqlConnection * 
        copyOptions:SqlBulkCopyOptions * 
        externalTransaction:SqlTransaction -> SqlBulkCopy

Parameters

connection
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.

copyOptions
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.

externalTransaction
Type: System.Data.SqlClient.SqlTransaction

An existing SqlTransaction instance under which the bulk copy will occur.

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.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft