Send feedback on this topic.
Teradata.Client.Provider
TdDataReader Class
Members  Example 



Teradata.Client.Provider Namespace : TdDataReader Class
Represents a static forward-only cursor where the individual fields within the current row are accessible using the supported accessor methods.
Syntax
Remarks
TdDataReader does not expose a public constructor and therefore cannot be created by the end-user or application. An application must call the factory method, TdCommand.ExecuteReader, to execute a query and retrieve an instance of TdDataReader. TdDataReader encapsulates the data stream returned by the Advanced SQL Engine and exposes the values for each field within a row in addition to column metadata like column name, data type, size and precision.

The SQL Engine supports multiple open result sets per session, allowing multiple TdDataReader objects to be open at the same time. The Advanced SQL Engine supports up to 16 open result sets per session. Once TdDataReader is closed, the corresponding SQL result set is released and resources are freed.

It is highly recommended to close the TdDataReader object. You should not rely on garbage collection because it is nondeterministic, and valuable Server and Client resources would be left open. IsClosed and RecordsAffected are the only properties that you can call after the TdDataReader is closed. All other methods will throw an ObjectDisposdedException.

Example
The following example executes a query and displays the results.
public void DisplayDataReader(TdCommand cmd)
{
    TdDataReader reader = cmd.ExecuteReader();
    
    Console.WriteLine("{0} records affected.", reader.RecordsAffected);
    
    int currentRow = 1;
    while(reader.Read())
    {
        for (int columnIndex = 0; columnIndex < reader.FieldCount; columnIndex++)
        {
            Console.WriteLine("Field [{0,4}] [{1,30}] = {2}", 
                    currentRow, reader.GetName(columnIndex), 
                    reader.GetValue(columnIndex)); 
        }
        
        Console.WriteLine();
        
        currentRow++;
    }
    
    reader.Close();
}
Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.Data.Common.DbDataReader
         Teradata.Client.Provider.TdDataReader

Requirements

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

See Also

Reference

TdDataReader Members
Teradata.Client.Provider Namespace