Share via


SqlBulkCopy.WriteToServerAsync Method

Definition

Overloads

WriteToServerAsync(DataTable, CancellationToken)

The asynchronous version of WriteToServer(DataTable), 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.

WriteToServerAsync(DataTable, DataRowState)

The asynchronous version of WriteToServer(DataTable, DataRowState), 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.

WriteToServerAsync(DataRow[], CancellationToken)

The asynchronous version of WriteToServer(DataRow[]), 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.

WriteToServerAsync(DbDataReader, CancellationToken)

The asynchronous version of WriteToServer(DbDataReader), which copies all rows from the supplied DbDataReader 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.

WriteToServerAsync(DataTable, DataRowState, CancellationToken)

The asynchronous version of WriteToServer(DataTable, DataRowState), 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.

WriteToServerAsync(DataTable)

The asynchronous version of WriteToServer(DataTable), which copies all rows in the supplied DataTable to a destination table specified by the DestinationTableName property of the SqlBulkCopy object.

WriteToServerAsync(DataRow[])

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

WriteToServerAsync(DbDataReader)

The asynchronous version of WriteToServer(IDataReader), which copies all rows in the supplied IDataReader to a destination table specified by the DestinationTableName property of the SqlBulkCopy object.

WriteToServerAsync(IDataReader, CancellationToken)

The asynchronous version of WriteToServer(IDataReader), 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.

WriteToServerAsync(IDataReader)

The asynchronous version of WriteToServer(IDataReader), which copies all rows in the supplied IDataReader to a destination table specified by the DestinationTableName property of the SqlBulkCopy object.

WriteToServerAsync(DataTable, CancellationToken)

The asynchronous version of WriteToServer(DataTable), 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:
 System::Threading::Tasks::Task ^ WriteToServerAsync(System::Data::DataTable ^ table, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task WriteToServerAsync (System.Data.DataTable table, System.Threading.CancellationToken cancellationToken);
member this.WriteToServerAsync : System.Data.DataTable * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function WriteToServerAsync (table As DataTable, cancellationToken As CancellationToken) As Task

Parameters

table
DataTable

A DataTable whose rows will be copied to the destination table.

cancellationToken
CancellationToken

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

Returns

A task representing the asynchronous operation.

Exceptions

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

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

The connection drops or is closed during WriteToServerAsync(DataTable) 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.

A SqlBulkCopyColumnOrderHint did not specify a valid destination column name.

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

Remarks

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

Applies to

WriteToServerAsync(DataTable, DataRowState)

The asynchronous version of WriteToServer(DataTable, DataRowState), 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:
 System::Threading::Tasks::Task ^ WriteToServerAsync(System::Data::DataTable ^ table, System::Data::DataRowState rowState);
public System.Threading.Tasks.Task WriteToServerAsync (System.Data.DataTable table, System.Data.DataRowState rowState);
member this.WriteToServerAsync : System.Data.DataTable * System.Data.DataRowState -> System.Threading.Tasks.Task
Public Function WriteToServerAsync (table As DataTable, rowState As DataRowState) As Task

Parameters

table
DataTable

A DataTable whose rows will be copied to the destination table.

rowState
DataRowState

A value from the DataRowState enumeration. Only rows matching the row state are copied to the destination.

Returns

A task representing the asynchronous operation.

Exceptions

Calling WriteToServerAsync(DataTable, DataRowState) multiple times for the same instance before task completion.

Calling WriteToServerAsync(DataTable, DataRowState) and WriteToServer(DataTable, DataRowState) for the same instance before task completion.

The connection drops or is closed during WriteToServerAsync(DataTable, DataRowState) 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.

A SqlBulkCopyColumnOrderHint did not specify a valid destination column name.

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

Remarks

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

Applies to

WriteToServerAsync(DataRow[], CancellationToken)

The asynchronous version of WriteToServer(DataRow[]), 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:
 System::Threading::Tasks::Task ^ WriteToServerAsync(cli::array <System::Data::DataRow ^> ^ rows, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task WriteToServerAsync (System.Data.DataRow[] rows, System.Threading.CancellationToken cancellationToken);
member this.WriteToServerAsync : System.Data.DataRow[] * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function WriteToServerAsync (rows As DataRow(), cancellationToken As CancellationToken) As Task

Parameters

rows
DataRow[]

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

cancellationToken
CancellationToken

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

Returns

A task representing the asynchronous operation.

Exceptions

Calling WriteToServerAsync(DataRow[]) multiple times for the same instance before task completion.

Calling WriteToServerAsync(DataRow[]) and WriteToServer(DataRow[]) for the same instance before task completion.

The connection drops or is closed during WriteToServerAsync(DataRow[]) 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.

A SqlBulkCopyColumnOrderHint did not specify a valid destination column name.

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

Remarks

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

Applies to

WriteToServerAsync(DbDataReader, CancellationToken)

The asynchronous version of WriteToServer(DbDataReader), which copies all rows from the supplied DbDataReader 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:
 System::Threading::Tasks::Task ^ WriteToServerAsync(System::Data::Common::DbDataReader ^ reader, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task WriteToServerAsync (System.Data.Common.DbDataReader reader, System.Threading.CancellationToken cancellationToken);
member this.WriteToServerAsync : System.Data.Common.DbDataReader * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function WriteToServerAsync (reader As DbDataReader, cancellationToken As CancellationToken) As Task

Parameters

reader
DbDataReader

A DbDataReader whose rows will be copied to the destination table.

cancellationToken
CancellationToken

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

Returns

A task representing the asynchronous operation.

Applies to

WriteToServerAsync(DataTable, DataRowState, CancellationToken)

The asynchronous version of WriteToServer(DataTable, DataRowState), 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.

public:
 System::Threading::Tasks::Task ^ WriteToServerAsync(System::Data::DataTable ^ table, System::Data::DataRowState rowState, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task WriteToServerAsync (System.Data.DataTable table, System.Data.DataRowState rowState, System.Threading.CancellationToken cancellationToken);
member this.WriteToServerAsync : System.Data.DataTable * System.Data.DataRowState * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function WriteToServerAsync (table As DataTable, rowState As DataRowState, cancellationToken As CancellationToken) As Task

Parameters

table
DataTable

A DataTable whose rows will be copied to the destination table.

rowState
DataRowState

A value from the DataRowState enumeration. Only rows matching the row state are copied to the destination.

cancellationToken
CancellationToken

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

Returns

A task representing the asynchronous operation.

Exceptions

Calling WriteToServerAsync(DataTable, DataRowState) multiple times for the same instance before task completion.

Calling WriteToServerAsync(DataTable, DataRowState) and WriteToServer(DataTable, DataRowState) for the same instance before task completion.

The connection drops or is closed during WriteToServerAsync(DataTable, DataRowState) 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.

A SqlBulkCopyColumnOrderHint did not specify a valid destination column name.

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

Remarks

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

Applies to

WriteToServerAsync(DataTable)

The asynchronous version of WriteToServer(DataTable), which copies all rows in the supplied DataTable to a destination table specified by the DestinationTableName property of the SqlBulkCopy object.

public:
 System::Threading::Tasks::Task ^ WriteToServerAsync(System::Data::DataTable ^ table);
public System.Threading.Tasks.Task WriteToServerAsync (System.Data.DataTable table);
member this.WriteToServerAsync : System.Data.DataTable -> System.Threading.Tasks.Task
Public Function WriteToServerAsync (table As DataTable) As Task

Parameters

table
DataTable

A DataTable whose rows will be copied to the destination table.

Returns

A task representing the asynchronous operation.

Exceptions

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

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

The connection drops or is closed during WriteToServerAsync(DataTable) 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.

A SqlBulkCopyColumnOrderHint did not specify a valid destination column name.

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

Remarks

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

Applies to

WriteToServerAsync(DataRow[])

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

public:
 System::Threading::Tasks::Task ^ WriteToServerAsync(cli::array <System::Data::DataRow ^> ^ rows);
public System.Threading.Tasks.Task WriteToServerAsync (System.Data.DataRow[] rows);
member this.WriteToServerAsync : System.Data.DataRow[] -> System.Threading.Tasks.Task
Public Function WriteToServerAsync (rows As DataRow()) As Task

Parameters

rows
DataRow[]

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

Returns

A task representing the asynchronous operation.

Exceptions

Calling WriteToServerAsync(DataRow[]) multiple times for the same instance before task completion. Calling WriteToServerAsync(DataRow[]) and WriteToServer(DataRow[]) for the same instance before task completion.

The connection drops or is closed during WriteToServerAsync(DataRow[]) 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.

A SqlBulkCopyColumnOrderHint did not specify a valid destination column name.

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

Remarks

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

Applies to

WriteToServerAsync(DbDataReader)

The asynchronous version of WriteToServer(IDataReader), which copies all rows in the supplied IDataReader to a destination table specified by the DestinationTableName property of the SqlBulkCopy object.

public:
 System::Threading::Tasks::Task ^ WriteToServerAsync(System::Data::Common::DbDataReader ^ reader);
public System.Threading.Tasks.Task WriteToServerAsync (System.Data.Common.DbDataReader reader);
member this.WriteToServerAsync : System.Data.Common.DbDataReader -> System.Threading.Tasks.Task
Public Function WriteToServerAsync (reader As DbDataReader) As Task

Parameters

reader
DbDataReader

A IDataReader whose rows will be copied to the destination table.

Returns

A task representing the asynchronous operation.

Exceptions

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

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

The connection drops or is closed during WriteToServerAsync(IDataReader) 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.

The IDataReader was closed before the completed Task returned.

The IDataReader's associated connection was closed before the completed Task returned.

A SqlBulkCopyColumnOrderHint did not specify a valid destination column name.

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

Remarks

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

Applies to

WriteToServerAsync(IDataReader, CancellationToken)

The asynchronous version of WriteToServer(IDataReader), 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:
 System::Threading::Tasks::Task ^ WriteToServerAsync(System::Data::IDataReader ^ reader, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task WriteToServerAsync (System.Data.IDataReader reader, System.Threading.CancellationToken cancellationToken);
member this.WriteToServerAsync : System.Data.IDataReader * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function WriteToServerAsync (reader As IDataReader, cancellationToken As CancellationToken) As Task

Parameters

reader
IDataReader

A IDataReader whose rows will be copied to the destination table.

cancellationToken
CancellationToken

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

Returns

A task representing the asynchronous operation.

Exceptions

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

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

The connection drops or is closed during WriteToServerAsync(IDataReader) 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.

The IDataReader was closed before the completed Task returned.

The IDataReader's associated connection was closed before the completed Task returned.

A SqlBulkCopyColumnOrderHint did not specify a valid destination column name.

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

Remarks

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

Applies to

WriteToServerAsync(IDataReader)

The asynchronous version of WriteToServer(IDataReader), which copies all rows in the supplied IDataReader to a destination table specified by the DestinationTableName property of the SqlBulkCopy object.

public:
 System::Threading::Tasks::Task ^ WriteToServerAsync(System::Data::IDataReader ^ reader);
public System.Threading.Tasks.Task WriteToServerAsync (System.Data.IDataReader reader);
member this.WriteToServerAsync : System.Data.IDataReader -> System.Threading.Tasks.Task
Public Function WriteToServerAsync (reader As IDataReader) As Task

Parameters

reader
IDataReader

A IDataReader whose rows will be copied to the destination table.

Returns

A task representing the asynchronous operation.

Exceptions

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

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

The connection drops or is closed during WriteToServerAsync(IDataReader) 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.

The IDataReader was closed before the completed Task returned.

The IDataReader's associated connection was closed before the completed Task returned.

A SqlBulkCopyColumnOrderHint did not specify a valid destination column name.

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

Remarks

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

Applies to