Export (0) Print
Expand All

SqlBulkCopy.WriteToServerAsync Method

.NET Framework 4.5

An asynchronous version of WriteToServer, which copies all rows from a data source to a destination table specified by the DestinationTableName property of the SqlBulkCopy object.

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

  Name Description
Public method WriteToServerAsync(DataRow[]) 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.
Public method WriteToServerAsync(DataTable) The asynchronous version of WriteToServer, which copies all rows in the supplied DataTable to a destination table specified by the DestinationTableName property of the SqlBulkCopy object.
Public method WriteToServerAsync(IDataReader) The asynchronous version of WriteToServer, which copies all rows in the supplied IDataReader to a destination table specified by the DestinationTableName property of the SqlBulkCopy object.
Public method WriteToServerAsync(DataRow[], CancellationToken) 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.
Public method WriteToServerAsync(DataTable, DataRowState) The asynchronous version of WriteToServer, which copies only rows that match the supplied row state in the supplied DataTable to a destination table specified by the DestinationTableName property of the SqlBulkCopy object.
Public method WriteToServerAsync(DataTable, CancellationToken) The asynchronous version of WriteToServer, which copies all rows in the supplied DataTable 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.
Public method WriteToServerAsync(IDataReader, CancellationToken) The asynchronous version of WriteToServer, which copies all rows in the supplied IDataReader 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.
Public method WriteToServerAsync(DataTable, DataRowState, CancellationToken) The asynchronous version of WriteToServer, which copies only rows that match the supplied row state in the supplied DataTable 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.
Top

If multiple active result sets (MARS) is disabled, WriteToServer makes the connection busy. If MARS is enabled, you can interleave calls to WriteToServer with other commands in the same connection.

The number of rows that are rolled back when one fails depends on several things:

When there is an error while sending data to the server, the current batch (as specified by BatchSize) will be rolled back. If UseInternalTransaction is not specified and you have your own transaction, the entire transaction will be rolled back (which includes all previous batches as well).

Use SqlRowsCopied to know how many rows were copied to the server.

Show:
© 2014 Microsoft