TdStream is used to retrieve a BLOB from the Teradata Vantage Advanced SQL Engine.
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;
}
Target Platforms: Windows 8.1, Windows 10, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019