Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
EndExecuteNonQuery Method

SqlCommand.EndExecuteNonQuery Method

Finishes asynchronous execution of a Transact-SQL statement.

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

public int EndExecuteNonQuery (
	IAsyncResult asyncResult
public int EndExecuteNonQuery (
	IAsyncResult asyncResult
public function EndExecuteNonQuery (
	asyncResult : IAsyncResult
) : int
Not applicable.



The IAsyncResult returned by the call to BeginExecuteNonQuery.

Return Value

The number of rows affected (the same behavior as ExecuteNonQuery).

Exception typeCondition


asyncResult parameter is null (Nothing in Microsoft Visual Basic)


EndExecuteNonQuery was called more than once for a single command execution, or the method was mismatched against its execution method (for example, the code called EndExecuteNonQuery to complete execution of a call to BeginExecuteXmlReader.

When you call BeginExecuteNonQuery to execute a Transact-SQL statement, you must call EndExecuteNonQuery in order to complete the operation. If the process of executing the command has not yet finished, this method blocks until the operation is complete. Users can verify that the command has completed its operation by using the IAsyncResult instance returned by the BeginExecuteNonQuery method. If a callback procedure was specified in the call to BeginExecuteNonQuery, this method must be called.

For examples demonstrating the use of the EndExecuteNonQuery method, see BeginExecuteNonQuery.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

© 2015 Microsoft