Send feedback on this topic.
Teradata.Client.Provider
BeginExecuteNonQuery() Method
Example 



Teradata.Client.Provider Namespace > TdCommand Class > BeginExecuteNonQuery Method : BeginExecuteNonQuery() Method
Initiates the asynchronous request that is to be submitted to Teradata. This method differs from TdCommand.BeginExecuteReader in that it should not be used when retrieving data. A TdDataReader object is not returned when the corresponding TdCommand.EndExecuteNonQuery method is called.
Syntax
'Declaration
 
Public Overloads Function BeginExecuteNonQuery() As IAsyncResult
'Usage
 
Dim instance As TdCommand
Dim value As IAsyncResult
 
value = instance.BeginExecuteNonQuery()
public IAsyncResult BeginExecuteNonQuery()
public:
IAsyncResult^ BeginExecuteNonQuery(); 

Return Value

Returns a IAsyncResult object.
Exceptions
ExceptionDescription
The TdParameter.Offset is outside of 0 through array size � 1.
One or more parameters cannot be converted to Teradata Database native types.
Can be thrown because of one of the following errors: 1) TdConnection is not in Open state or is null or 2) The local transaction associated with the TdCommand is not the same local transaction associated with the TdConnection. Assign the local transaction to Transaction property.
The TdCommand is closed / disposed.
Can be thrown because the Data Provider detected an error.
Remarks

The call to BeginExecuteNonQuery returns after the request has been successfully sent to Teradata. Any exceptions that are generated by the provider while initializing the request will be thrown during the call to BeginExecuteNonQuery. Exceptions that are generated by the provider or Teradata during the processing of the request will be thrown when TdCommand.EndExecuteNonQuery is called.

The DDL statement CREATE PROCEDURE cannot be specified in an asynchronous execution. If it has been specified a TdException will be thrown when TdCommand.EndExecuteNonQuery is called.

A connection can only have one active request. Therefore, if an asynchronous request is being processed by the provider an exception will be thrown when an attempt is made to start another asynchronous request.

The TdCommand.CommandTimeout property is not applicable to asynchronous execution and will be ignored when a command is asynchronously executed.

Refer to TdCommand.ExecuteNonQuery for more information.

Example
The following example invokes an asynchronous request.
public void BeginExecute(String connectionString, String CommandText)
{
    TdConnection cn = new TdConnection(connectionString);
    cn.Open();
    
    IAsyncResult asyncResult;
            
    TdCommand cmd = new TdCommand(commandText, cn);
            
    //going to start asynchronous request
    asyncResult = cmd.BeginExecuteNonQuery();
            
    // going to perform other tasks
            
    //waiting for asynchronous execute to finish
    asyncResult.AsyncWaitHandle.WaitOne();
            
    //going to end the asynchronous request
    cmd.EndExecuteNonQuery(asyncResult);
            
     cn.Close();
}
Requirements

Target Platforms: Windows 8.1, Windows 10, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019

See Also

Reference

TdCommand Class
TdCommand Members
Overload List
ExecuteNonQuery Method