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



Teradata.Client.Provider Namespace > TdCommand Class > BeginExecuteReader Method : BeginExecuteReader() Method
Initiates the asynchronous request and generates one or more result sets from Teradata.
Syntax
'Declaration
 
Public Overloads Function BeginExecuteReader() As IAsyncResult
'Usage
 
Dim instance As TdCommand
Dim value As IAsyncResult
 
value = instance.BeginExecuteReader()
public IAsyncResult BeginExecuteReader()
public:
IAsyncResult^ BeginExecuteReader(); 

Return Value

Returns a IAsyncResult object.
Exceptions
ExceptionDescription
Indicates the TdParameter.Offset is outside of 0 through array size � 1.
Indicates one or more parameters cannot be converted to Teradata 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 BeginExecuteReader 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 BeginExecuteReader. Exceptions that are generated by the provider or Teradata during the processing of the request will be thrown when TdCommand.EndExecuteReader 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.EndExecuteReader 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.ExecuteReader for more information.

Example
The following example invokes an asynchronous request.
public void BeginExecute(String connectionString, String CommandText,
out TdConnection cn)
{
    cn = new TdConnection(connectionString);
    cn.Open();
    
    IAsyncResult asyncResult;
            
    TdCommand cmd = TdCommand(commandText, cn);
            
     //going to start asynchronous request
     asyncResult = cmd.BeginExecuteReader();
            
     // going to perform other tasks
            
     //going to end the asynchronous request
     //this will also block until processing has completed
     TdDataReader dataReader = cmd.EndExecuteReader(asyncResult);
            
      //RETRIEVE RESULTS FROM TERADATA
            
      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