SqlBulkCopy.WriteToServerAsync Method

Definition

WriteToServer 的非同步版本,它會將所有資料列從資料來源複製到 SqlBulkCopy 物件的 DestinationTableName 屬性所指定的目的資料表。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.

Overloads

WriteToServerAsync(IDataReader, CancellationToken)

WriteToServer(IDataReader) 的非同步版本,它會將提供之 IDataReader 內的所有資料列複製到 SqlBulkCopy 物件之 DestinationTableName 屬性所指定的目的資料表。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. 例外狀況將經由傳回的 Task 物件回報。Exceptions will be reported via the returned Task object.

WriteToServerAsync(DbDataReader)

WriteToServer(DbDataReader) 的非同步版本,它會將所有資料列從提供的 DbDataReader 陣列複製到 SqlBulkCopy 物件之 DestinationTableName 屬性所指定的目的資料表。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.

WriteToServerAsync(DataRow[])

WriteToServer(DataRow[]) 的非同步版本,它會將所有資料列從提供的 DataRow 陣列複製到 SqlBulkCopy 物件之 DestinationTableName 屬性所指定的目的資料表。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(DataTable)

WriteToServer(DataTable) 的非同步版本,它會將提供之 DataTable 內的所有資料列複製到 SqlBulkCopy 物件之 DestinationTableName 屬性所指定的目的資料表。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(IDataReader)

WriteToServer(IDataReader) 的非同步版本,它會將提供之 IDataReader 內的所有資料列複製到 SqlBulkCopy 物件之 DestinationTableName 屬性所指定的目的資料表。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(DbDataReader, CancellationToken)

WriteToServer(DbDataReader) 的非同步版本,它會將所有資料列從提供的 DbDataReader 陣列複製到 SqlBulkCopy 物件之 DestinationTableName 屬性所指定的目的資料表。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.

WriteToServerAsync(DataRow[], CancellationToken)

WriteToServer(DataRow[]) 的非同步版本,它會將所有資料列從提供的 DataRow 陣列複製到 SqlBulkCopy 物件之 DestinationTableName 屬性所指定的目的資料表。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. 例外狀況將經由傳回的 Task 物件回報。Exceptions will be reported via the returned Task object.

WriteToServerAsync(DataTable, DataRowState)

WriteToServer(DataTable, DataRowState) 的非同步版本,它只會將提供的 DataTable 之內符合提供的資料列狀態之資料列複製到 SqlBulkCopy 物件之 DestinationTableName 屬性所指定的目的資料表。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(DataTable, CancellationToken)

WriteToServer(DataTable) 的非同步版本,它會將提供之 DataTable 內的所有資料列複製到 SqlBulkCopy 物件之 DestinationTableName 屬性所指定的目的資料表。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. 例外狀況將經由傳回的 Task 物件回報。Exceptions will be reported via the returned Task object.

WriteToServerAsync(DataTable, DataRowState, CancellationToken)

WriteToServer(DataTable, DataRowState) 的非同步版本,它只會將提供的 DataTable 之內符合提供的資料列狀態之資料列複製到 SqlBulkCopy 物件之 DestinationTableName 屬性所指定的目的資料表。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. 例外狀況將經由傳回的 Task 物件回報。Exceptions will be reported via the returned Task object.

Remarks

如果已停用 multiple active result sets (MARS),WriteToServer 會使連接忙碌。If multiple active result sets (MARS) is disabled, WriteToServer makes the connection busy. 如果已啟用 MARS,您可以使用相同連接中的其他命令,將 WriteToServer 的呼叫交錯。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:

將資料傳送至伺服器時發生錯誤時,將會回復目前的批次(如 BatchSize所指定)。When there is an error while sending data to the server, the current batch (as specified by BatchSize) will be rolled back. 如果未指定 UseInternalTransaction,而且您有自己的交易,則會回復整個交易(也包括所有先前的批次)。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).

使用 SqlRowsCopied 來知道已將多少資料列複製到伺服器。Use SqlRowsCopied to know how many rows were copied to the server.

WriteToServerAsync(IDataReader, CancellationToken)

WriteToServer(IDataReader) 的非同步版本,它會將提供之 IDataReader 內的所有資料列複製到 SqlBulkCopy 物件之 DestinationTableName 屬性所指定的目的資料表。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. 例外狀況將經由傳回的 Task 物件回報。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

IDataReader,其資料列會複製到目的資料表。A IDataReader whose rows will be copied to the destination table.

cancellationToken
CancellationToken

取消指令。The cancellation instruction. 這個參數中的 None 值會使這個方法相當於 WriteToServerAsync(DataTable)A None value in this parameter makes this method equivalent to WriteToServerAsync(DataTable).

Returns

Task

表示非同步作業的工作。A task representing the asynchronous operation.

Exceptions

在工作完成前,多次呼叫同一個執行個體的 WriteToServerAsync(IDataReader)Calling WriteToServerAsync(IDataReader) multiple times for the same instance before task completion.

在工作完成前,對同一個執行個體呼叫 WriteToServerAsync(IDataReader)WriteToServer(IDataReader)Calling WriteToServerAsync(IDataReader) and WriteToServer(IDataReader) for the same instance before task completion.

WriteToServerAsync(IDataReader) 執行期間卸除或關閉連接。The connection drops or is closed during WriteToServerAsync(IDataReader) execution.

於工作物件中傳回,在方法執行期間已關閉 SqlBulkCopy 物件。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.

於工作物件中傳回,在方法執行前已關閉 SqlConnection 物件。Returned in the task object, the SqlConnection object is closed before method execution.

在已完成的 Task 傳回之前,IDataReader 已關閉。The IDataReader was closed before the completed Task returned.

在已完成的 Task 傳回之前,IDataReader 的相關聯連接已關閉。The IDataReader's associated connection was closed before the completed Task returned.

在連接字串中指定了 Context Connection=trueContext Connection=true is specified in the connection string.

於工作物件中傳回,SQL Server 傳回於開啟連線時所發生的任何錯誤。Returned in the task object, any error returned by SQL Server that occurred while opening the connection.

Remarks

如需 SQL Server 的 .NET Framework Data Provider 中非同步程式設計的詳細資訊,請參閱非同步程式設計For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see Asynchronous Programming.

WriteToServerAsync(DbDataReader)

WriteToServer(DbDataReader) 的非同步版本,它會將所有資料列從提供的 DbDataReader 陣列複製到 SqlBulkCopy 物件之 DestinationTableName 屬性所指定的目的資料表。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.

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

DbDataReader,其資料列會複製到目的資料表。A DbDataReader whose rows will be copied to the destination table.

Returns

Task

表示非同步作業的工作。A task representing the asynchronous operation.

Remarks

如需 SQL Server 的 .NET Framework Data Provider 中非同步程式設計的詳細資訊,請參閱非同步程式設計For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see Asynchronous Programming.

WriteToServerAsync(DataRow[])

WriteToServer(DataRow[]) 的非同步版本,它會將所有資料列從提供的 DataRow 陣列複製到 SqlBulkCopy 物件之 DestinationTableName 屬性所指定的目的資料表。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[]

要複製到目的資料表的 DataRow 物件陣列。An array of DataRow objects that will be copied to the destination table.

Returns

Task

表示非同步作業的工作。A task representing the asynchronous operation.

Exceptions

在工作完成前,多次呼叫同一個執行個體的 WriteToServerAsync(DataRow[])Calling WriteToServerAsync(DataRow[]) multiple times for the same instance before task completion.

在工作完成前,對同一個執行個體呼叫 WriteToServerAsync(DataRow[])WriteToServer(DataRow[])Calling WriteToServerAsync(DataRow[]) and WriteToServer(DataRow[]) for the same instance before task completion.

WriteToServerAsync(DataRow[]) 執行期間卸除或關閉連接。The connection drops or is closed during WriteToServerAsync(DataRow[]) execution.

於工作物件中傳回,在方法執行期間已關閉 SqlBulkCopy 物件。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.

於工作物件中傳回,在方法執行前已關閉 SqlConnection 物件。Returned in the task object, the SqlConnection object is closed before method execution.

在連接字串中指定了 Context Connection=trueContext Connection=true is specified in the connection string.

於工作物件中傳回,SQL Server 傳回於開啟連線時所發生的任何錯誤。Returned in the task object, any error returned by SQL Server that occurred while opening the connection.

Remarks

如需 SQL Server 的 .NET Framework Data Provider 中非同步程式設計的詳細資訊,請參閱非同步程式設計For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see Asynchronous Programming.

WriteToServerAsync(DataTable)

WriteToServer(DataTable) 的非同步版本,它會將提供之 DataTable 內的所有資料列複製到 SqlBulkCopy 物件之 DestinationTableName 屬性所指定的目的資料表。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

DataTable,其資料列會複製到目的資料表。A DataTable whose rows will be copied to the destination table.

Returns

Task

表示非同步作業的工作。A task representing the asynchronous operation.

Exceptions

在工作完成前,多次呼叫同一個執行個體的 WriteToServerAsync(DataTable)Calling WriteToServerAsync(DataTable) multiple times for the same instance before task completion.

在工作完成前,對同一個執行個體呼叫 WriteToServerAsync(DataTable)WriteToServer(DataTable)Calling WriteToServerAsync(DataTable) and WriteToServer(DataTable) for the same instance before task completion.

WriteToServerAsync(DataTable) 執行期間卸除或關閉連接。The connection drops or is closed during WriteToServerAsync(DataTable) execution.

於工作物件中傳回,在方法執行期間已關閉 SqlBulkCopy 物件。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.

於工作物件中傳回,在方法執行前已關閉 SqlConnection 物件。Returned in the task object, the SqlConnection object is closed before method execution.

在連接字串中指定了 Context Connection=trueContext Connection=true is specified in the connection string.

於工作物件中傳回,SQL Server 傳回於開啟連線時所發生的任何錯誤。Returned in the task object, any error returned by SQL Server that occurred while opening the connection.

Remarks

如需 SQL Server 的 .NET Framework Data Provider 中非同步程式設計的詳細資訊,請參閱非同步程式設計For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see Asynchronous Programming.

WriteToServerAsync(IDataReader)

WriteToServer(IDataReader) 的非同步版本,它會將提供之 IDataReader 內的所有資料列複製到 SqlBulkCopy 物件之 DestinationTableName 屬性所指定的目的資料表。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

IDataReader,其資料列會複製到目的資料表。A IDataReader whose rows will be copied to the destination table.

Returns

Task

表示非同步作業的工作。A task representing the asynchronous operation.

Exceptions

在工作完成前,多次呼叫同一個執行個體的 WriteToServerAsync(IDataReader)Calling WriteToServerAsync(IDataReader) multiple times for the same instance before task completion.

在工作完成前,對同一個執行個體呼叫 WriteToServerAsync(IDataReader)WriteToServer(IDataReader)Calling WriteToServerAsync(IDataReader) and WriteToServer(IDataReader) for the same instance before task completion.

WriteToServerAsync(IDataReader) 執行期間卸除或關閉連接。The connection drops or is closed during WriteToServerAsync(IDataReader) execution.

於工作物件中傳回,在方法執行期間已關閉 SqlBulkCopy 物件。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.

於工作物件中傳回,在方法執行前已關閉 SqlConnection 物件。Returned in the task object, the SqlConnection object is closed before method execution.

在已完成的 Task 傳回之前,IDataReader 已關閉。The IDataReader was closed before the completed Task returned.

在已完成的 Task 傳回之前,IDataReader 的相關聯連接已關閉。The IDataReader's associated connection was closed before the completed Task returned.

在連接字串中指定了 Context Connection=trueContext Connection=true is specified in the connection string.

於工作物件中傳回,SQL Server 傳回於開啟連線時所發生的任何錯誤。Returned in the task object, any error returned by SQL Server that occurred while opening the connection.

Remarks

如需 SQL Server 的 .NET Framework Data Provider 中非同步程式設計的詳細資訊,請參閱非同步程式設計For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see Asynchronous Programming.

WriteToServerAsync(DbDataReader, CancellationToken)

WriteToServer(DbDataReader) 的非同步版本,它會將所有資料列從提供的 DbDataReader 陣列複製到 SqlBulkCopy 物件之 DestinationTableName 屬性所指定的目的資料表。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.

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

DbDataReader,其資料列會複製到目的資料表。A DbDataReader whose rows will be copied to the destination table.

cancellationToken
CancellationToken

取消指令。The cancellation instruction. 這個參數中的 None 值會使這個方法相當於 WriteToServerAsync(DbDataReader)A None value in this parameter makes this method equivalent to WriteToServerAsync(DbDataReader).

Returns

Task

傳回 TaskReturns Task.

WriteToServerAsync(DataRow[], CancellationToken)

WriteToServer(DataRow[]) 的非同步版本,它會將所有資料列從提供的 DataRow 陣列複製到 SqlBulkCopy 物件之 DestinationTableName 屬性所指定的目的資料表。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. 例外狀況將經由傳回的 Task 物件回報。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[]

要複製到目的資料表的 DataRow 物件陣列。An array of DataRow objects that will be copied to the destination table.

cancellationToken
CancellationToken

取消指令。The cancellation instruction. 這個參數中的 None 值會使這個方法相當於 WriteToServerAsync(DataTable)A None value in this parameter makes this method equivalent to WriteToServerAsync(DataTable).

Returns

Task

表示非同步作業的工作。A task representing the asynchronous operation.

Exceptions

在工作完成前,多次呼叫同一個執行個體的 WriteToServerAsync(DataRow[])Calling WriteToServerAsync(DataRow[]) multiple times for the same instance before task completion.

在工作完成前,對同一個執行個體呼叫 WriteToServerAsync(DataRow[])WriteToServer(DataRow[])Calling WriteToServerAsync(DataRow[]) and WriteToServer(DataRow[]) for the same instance before task completion.

WriteToServerAsync(DataRow[]) 執行期間卸除或關閉連接。The connection drops or is closed during WriteToServerAsync(DataRow[]) execution.

於工作物件中傳回,在方法執行期間已關閉 SqlBulkCopy 物件。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.

於工作物件中傳回,在方法執行前已關閉 SqlConnection 物件。Returned in the task object, the SqlConnection object is closed before method execution.

在連接字串中指定了 Context Connection=trueContext Connection=true is specified in the connection string.

於工作物件中傳回,SQL Server 傳回於開啟連線時所發生的任何錯誤。Returned in the task object, any error returned by SQL Server that occurred while opening the connection.

Remarks

如需 SQL Server 的 .NET Framework Data Provider 中非同步程式設計的詳細資訊,請參閱非同步程式設計For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see Asynchronous Programming.

WriteToServerAsync(DataTable, DataRowState)

WriteToServer(DataTable, DataRowState) 的非同步版本,它只會將提供的 DataTable 之內符合提供的資料列狀態之資料列複製到 SqlBulkCopy 物件之 DestinationTableName 屬性所指定的目的資料表。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

DataTable,其資料列會複製到目的資料表。A DataTable whose rows will be copied to the destination table.

rowState
DataRowState

DataRowState 列舉中的值。A value from the DataRowState enumeration. 只有符合資料列狀態的資料列會複製到目的地。Only rows matching the row state are copied to the destination.

Returns

Task

表示非同步作業的工作。A task representing the asynchronous operation.

Exceptions

在工作完成前,多次呼叫同一個執行個體的 WriteToServerAsync(DataTable, DataRowState)Calling WriteToServerAsync(DataTable, DataRowState) multiple times for the same instance before task completion.

在工作完成前,對同一個執行個體呼叫 WriteToServerAsync(DataTable, DataRowState)WriteToServer(DataTable, DataRowState)Calling WriteToServerAsync(DataTable, DataRowState) and WriteToServer(DataTable, DataRowState) for the same instance before task completion.

WriteToServerAsync(DataTable, DataRowState) 執行期間卸除或關閉連接。The connection drops or is closed during WriteToServerAsync(DataTable, DataRowState) execution.

於工作物件中傳回,在方法執行期間已關閉 SqlBulkCopy 物件。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.

於工作物件中傳回,在方法執行前已關閉 SqlConnection 物件。Returned in the task object, the SqlConnection object is closed before method execution.

在連接字串中指定了 Context Connection=trueContext Connection=true is specified in the connection string.

於工作物件中傳回,SQL Server 傳回於開啟連線時所發生的任何錯誤。Returned in the task object, any error returned by SQL Server that occurred while opening the connection.

Remarks

如需 SQL Server 的 .NET Framework Data Provider 中非同步程式設計的詳細資訊,請參閱非同步程式設計For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see Asynchronous Programming.

WriteToServerAsync(DataTable, CancellationToken)

WriteToServer(DataTable) 的非同步版本,它會將提供之 DataTable 內的所有資料列複製到 SqlBulkCopy 物件之 DestinationTableName 屬性所指定的目的資料表。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. 例外狀況將經由傳回的 Task 物件回報。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

DataTable,其資料列會複製到目的資料表。A DataTable whose rows will be copied to the destination table.

cancellationToken
CancellationToken

取消指令。The cancellation instruction. 這個參數中的 None 值會使這個方法相當於 WriteToServerAsync(DataTable)A None value in this parameter makes this method equivalent to WriteToServerAsync(DataTable).

Returns

Task

表示非同步作業的工作。A task representing the asynchronous operation.

Exceptions

在工作完成前,多次呼叫同一個執行個體的 WriteToServerAsync(DataTable)Calling WriteToServerAsync(DataTable) multiple times for the same instance before task completion.

在工作完成前,對同一個執行個體呼叫 WriteToServerAsync(DataTable)WriteToServer(DataTable)Calling WriteToServerAsync(DataTable) and WriteToServer(DataTable) for the same instance before task completion.

WriteToServerAsync(DataTable) 執行期間卸除或關閉連接。The connection drops or is closed during WriteToServerAsync(DataTable) execution.

於工作物件中傳回,在方法執行期間已關閉 SqlBulkCopy 物件。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.

於工作物件中傳回,在方法執行前已關閉 SqlConnection 物件。Returned in the task object, the SqlConnection object is closed before method execution.

在連接字串中指定了 Context Connection=trueContext Connection=true is specified in the connection string.

於工作物件中傳回,SQL Server 傳回於開啟連線時所發生的任何錯誤。Returned in the task object, any error returned by SQL Server that occurred while opening the connection.

Remarks

如需 SQL Server 的 .NET Framework Data Provider 中非同步程式設計的詳細資訊,請參閱非同步程式設計For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see Asynchronous Programming.

WriteToServerAsync(DataTable, DataRowState, CancellationToken)

WriteToServer(DataTable, DataRowState) 的非同步版本,它只會將提供的 DataTable 之內符合提供的資料列狀態之資料列複製到 SqlBulkCopy 物件之 DestinationTableName 屬性所指定的目的資料表。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. 例外狀況將經由傳回的 Task 物件回報。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

DataTable,其資料列會複製到目的資料表。A DataTable whose rows will be copied to the destination table.

rowState
DataRowState

DataRowState 列舉中的值。A value from the DataRowState enumeration. 只有符合資料列狀態的資料列會複製到目的地。Only rows matching the row state are copied to the destination.

cancellationToken
CancellationToken

取消指令。The cancellation instruction. 這個參數中的 None 值會使這個方法相當於 WriteToServerAsync(DataTable)A None value in this parameter makes this method equivalent to WriteToServerAsync(DataTable).

Returns

Task

表示非同步作業的工作。A task representing the asynchronous operation.

Exceptions

在工作完成前,多次呼叫同一個執行個體的 WriteToServerAsync(DataTable, DataRowState)Calling WriteToServerAsync(DataTable, DataRowState) multiple times for the same instance before task completion.

在工作完成前,對同一個執行個體呼叫 WriteToServerAsync(DataTable, DataRowState)WriteToServer(DataTable, DataRowState)Calling WriteToServerAsync(DataTable, DataRowState) and WriteToServer(DataTable, DataRowState) for the same instance before task completion.

WriteToServerAsync(DataTable, DataRowState) 執行期間卸除或關閉連接。The connection drops or is closed during WriteToServerAsync(DataTable, DataRowState) execution.

於工作物件中傳回,在方法執行期間已關閉 SqlBulkCopy 物件。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.

於工作物件中傳回,在方法執行前已關閉 SqlConnection 物件。Returned in the task object, the SqlConnection object is closed before method execution.

在連接字串中指定了 Context Connection=trueContext Connection=true is specified in the connection string.

於工作物件中傳回,SQL Server 傳回於開啟連線時所發生的任何錯誤。Returned in the task object, any error returned by SQL Server that occurred while opening the connection.

Remarks

如需 SQL Server 的 .NET Framework Data Provider 中非同步程式設計的詳細資訊,請參閱非同步程式設計For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see Asynchronous Programming.

Applies to