rty.

###  See also

  * [ Connecting and Retrieving Data in ADO.NET ](/en-us/dotnet/framework/data/adonet/retrieving-and-modifying-data)
  * [ Using the .NET Framework Data Provider for SQL Server ](/en-us/dotnet/framework/data/adonet/sql/)
  * [ ADO.NET Overview ](/en-us/dotnet/framework/data/adonet/ado-net-overview)

###  Applies to

##  BeginExecuteNonQuery(AsyncCallback, Object)

Initiates the asynchronous execution of the Transact-SQL statement or stored
procedure that is described by this [ SqlCommand
](system.data.sqlclient.sqlcommand?view=dotnet-plat-ext-8.0) , given a
callback procedure and state information.

    
    
    public:
     IAsyncResult ^ BeginExecuteNonQuery(AsyncCallback ^ callback, System::Object ^ stateObject);
    
    
    public IAsyncResult BeginExecuteNonQuery (AsyncCallback callback, object stateObject);
    
    
    member this.BeginExecuteNonQuery : AsyncCallback * obj -> IAsyncResult
    
    
    Public Function BeginExecuteNonQuery (callback As AsyncCallback, stateObject As Object) As IAsyncResult

####  Parameters

callback

     [ AsyncCallback ](system.asynccallback?view=dotnet-plat-ext-8.0)

An [ AsyncCallback ](system.asynccallback?view=dotnet-plat-ext-8.0) delegate
that is invoked when the command's execution has completed. Pass ` null ` ( `
Nothing ` in Microsoft Visual Basic) to indicate that no callback is required.

stateObject

     [ Object ](system.object?view=dotnet-plat-ext-8.0)

A user-defined state object that is passed to the callback procedure. Retrieve
this object from within the callback procedure using the [ AsyncState
](system.iasyncresult.asyncstate?view=dotnet-plat-ext-8.0#system-iasyncresult-
asyncstate) property.

####  Returns

[ IAsyncResult ](system.iasyncresult?view=dotnet-plat-ext-8.0)

An [ IAsyncResult ](system.iasyncresult?view=dotnet-plat-ext-8.0) that can be
used to poll or wait for results, or both; this value is also needed when
invoking [ EndExecuteNonQuery(IAsyncResult)
](system.data.sqlclient.sqlcommand.endexecutenonquery?view=dotnet-plat-
ext-8.0#system-data-sqlclient-sqlcommand-endexecutenonquery\(system-
iasyncresult\)) , which returns the number of affected rows.

####  Exceptions

[ InvalidCastException ](system.invalidcastexception?view=dotnet-plat-ext-8.0)

A [ SqlDbType ](system.data.sqlclient.sqlparameter.sqldbtype?view=dotnet-plat-
ext-8.0#system-data-sqlclient-sqlparameter-sqldbtype) other than **Binary** or
**VarBinary** was used when [ Value
](system.data.sqlclient.sqlparameter.value?view=dotnet-plat-ext-8.0#system-
data-sqlclient-sqlparameter-value) was set to [ Stream
](system.io.stream?view=dotnet-plat-ext-8.0) . For more information about
streaming, see [ SqlClient Streaming Support ](/en-
us/dotnet/framework/data/adonet/sqlclient-streaming-support) .

-or- 

A [ SqlDbType ](system.data.sqlclient.sqlparameter.sqldbtype?view=dotnet-plat-
ext-8.0#system-data-sqlclient-sqlparameter-sqldbtype) other than **Char** ,
**NChar** , **NVarChar** , **VarChar** , or **Xml** was used when [ Value
](system.data.sqlclient.sqlparameter.value?view=dotnet-plat-ext-8.0#system-
data-sqlclient-sqlparameter-value) was set to [ TextReader
](system.io.textreader?view=dotnet-plat-ext-8.0) .

-or- 

A [ SqlDbType ](system.data.sqlclient.sqlparameter.sqldbtype?view=dotnet-plat-
ext-8.0#system-data-sqlclient-sqlparameter-sqldbtype) other than **Xml** was
used when [ Value ](system.data.sqlclient.sqlparameter.value?view=dotnet-plat-
ext-8.0#system-data-sqlclient-sqlparameter-value) was set to [ XmlReader
](system.xml.xmlreader?view=dotnet-plat-ext-8.0) .

[ SqlException ](system.data.sqlclient.sqlexception?view=dotnet-plat-ext-8.0)

Any error that occurred while executing the command text.

-or- 

A timeout occurred during a streaming operation. For more information about
streaming, see [ SqlClient Streaming Support ](/en-
us/dotnet/framework/data/adonet/sqlclient-streaming-support) .

[ InvalidOperationException ](system.invalidoperationexception?view=dotnet