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



Teradata.Client.Provider Namespace > TdCommand Class > ExecuteReaderAsync Method : ExecuteReaderAsync() Method
A Task-based asynchronous version of the TdCommand.ExecuteReader method.
Syntax
'Declaration
 
Public Overloads Shadows Function ExecuteReaderAsync() As Task(Of TdDataReader)
'Usage
 
Dim instance As TdCommand
Dim value As Task(Of TdDataReader)
 
value = instance.ExecuteReaderAsync()
public new Task<TdDataReader> ExecuteReaderAsync()
public:
new Task<TdDataReader^>^ ExecuteReaderAsync(); 

Return Value

Returns a Task<TdDataReader> representing the asynchronous operation.
Exceptions
ExceptionDescription
Can be thrown because of one of the following errors: 1) TdCommand.Connection is not in Open state or is null. 2) TdCommand.CommandText is null or empty. 3) TdCommand has an open DataReader. 4) TdCommand has an active request. 5) The local transaction associated with TdCommand is not the same as the local transaction associated with TdConnection. Assign the local transaction to the TdCommand.Transaction property.
The TdCommand is closed / disposed.
.NET Data Provider for Teradata detected an error.
Remarks

Executes the SQL statement (TdCommand.CommandText property) by invoking TdCommand.ExecuteReaderAsync with CommandBehavior.Default and CancellationToken.None. Returns a Task<TdDataReader> representing the asynchronous operation. The task result is the static forward-only result set (TdDataReader).

When TdCommand.CommandType is set to StoredProcedure, any output parameters are populated with data. If the stored procedure does not return a dynamic result set, the resulting TdDataReader contains no rows.

Refer to Returning Data of Output Parameters in a Result Set for more information on the execution of stored procedures.

The .NET Data Provider allows more than one TdDataReader object to be open at any given time for each TdConnection. However, there can only be one TdDataReader for each TdCommand. TdDataReader must be closed before TdCommand can execute another SQL statement.

The .NET Data Provider supports In-Line and Deferred LOB retrievals. Using this method, LOBs are always retrieved in deferred mode, because this method invokes ExecuteReaderAsync(CommandBehavior, CancellationToken) with CommandBehavior.Default.

If this function generates a runtime exception, that exception will be wrapped in an AggregateException within the returned Task:

Exception Description
IndexOutOfRangeException Can be thrown because of one of the following errors: 1) The TdParameter.Offset is outside of 0 through array size � 1 2) More in-out/out parameters have been specified than returned from the stored procedure.
InvalidCastException One or more parameters cannot be converted to the Advanced SQL Engine native types.
OperationCanceledException The asynchronous operation was canceled.
TdException The Advanced SQL Engine returned an error, or .NET Data Provider for Teradata detected an error.
Example
See TdCommand.ExecuteReaderAsync for a code example.
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