Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

SqlBulkCopy.WriteToServerAsync Method (DataRow[], CancellationToken)

.NET Framework 4.6 and 4.5

The asynchronous version of WriteToServer, which copies all rows from the supplied DataRow array to a destination table specified by the DestinationTableName property of the SqlBulkCopy object.

The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object.

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

public Task WriteToServerAsync(
	DataRow[] rows,
	CancellationToken cancellationToken


Type: System.Data.DataRow[]

An array of DataRow objects that will be copied to the destination table.

Type: System.Threading.CancellationToken

The cancellation instruction. A None value in this parameter makes this method equivalent to WriteToServerAsync.

Return Value

Type: System.Threading.Tasks.Task
A task representing the asynchronous operation.


Calling WriteToServerAsync multiple times for the same instance before task completion.

Calling WriteToServerAsync and WriteToServer for the same instance before task completion.

The connection drops or is closed during WriteToServerAsync execution.

Returned in the task object, the SqlBulkCopy object was closed during the method execution.

Returned in the task object, there was a connection pool timeout.

Returned in the task object, the SqlConnection object is closed before method execution.

Context Connection=true is specified in the connection string.


Returned in the task object, any error returned by SQL Server that occurred while opening the connection.

For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see Asynchronous Programming.

.NET Framework

Supported in: 4.6, 4.5
© 2015 Microsoft