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



Teradata.Client.Provider Namespace : TdStream Class
TdStream is used to retrieve a BLOB from the Teradata Vantage Advanced SQL Engine.
Syntax
'Declaration
 
Public NotInheritable Class TdStream 
   Inherits System.IO.Stream
   Implements System.IDisposable 
'Usage
 
Dim instance As TdStream
public sealed class TdStream : System.IO.Stream, System.IDisposable  
public ref class TdStream sealed : public System.IO.Stream, System.IDisposable  
Remarks

TdStream represents a System.IO.Stream through which raw data (bytes) associated with a BLOB field can be read. Optionally, System.IO.BinaryReader and System.IO.StreamReader is used in conjunction with TdStream for reading of primitive .NET data types. TdStream does not support seeking; an application cannot modify the current position within the stream.

TdStream represents a read-only BLOB and an open query against the SQL Engine when CommandBehavior.SequentialAccess is not requested by the application. This query is separate and distinct from the query associated with the TdDataReader. Therefore the maximum number of open SQL queries (16) limit applies to TdDataReader and TdStream. See TdBlob for additional information.

TdStream implements IDisposable interface. It is highly recommended that Dispose or Close be called before an instance of this class is released for garbage collection. Since garbage collection is not deterministic, valuable SQL Engine resources might not be released immediately. The TdStream is disposed when a TdBlob object is disposed.

Example
The following example returns a TdStream (TdBlob.BaseStream property) representing an Employee picture. It uses a connection to Teradata to execute a query against the Employee table.
public void TdStream GetEmployeePicture(String employeeId, TdConnection cn)
{
    TdCommand cmd = new TdCommand(“Select Pic from Employee Where ID = ?”, cn);
            
    // Initialize the parameter with employee ID.
    TdParameter id = cmd.CreateParameter();
    id.ParameterName = “EmployeeID”;
    id.Direction = System.Data.ParameterDirection.Input;
    id.Value = employeeId;
            
    // Execute the query. Note This example will not work if 
    // CommandBehavior.SequentialAccess is specified since 
    // the reader is Closed/Disposed before the call returns.
    TdDataReader rd = cmd.ExecuteReader();
            
    // Retrieve the picture
    TdBlob employeePicture = rd.GetTdBlob(0);
            
    // Dispose of the reader and command
    rd.Close();
    cmd.Dispose();
    	
    // return the employee picture stream.
    return employeePicture.BaseStream;	
}
Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.IO.Stream
         Teradata.Client.Provider.TdStream

Requirements

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

See Also

Reference

TdStream Members
Teradata.Client.Provider Namespace
TdBlob Class