TdStream is used to retrieve a BLOB from Teradata Database.
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 7, Windows 8, Windows 8.1, Windows 10, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2