I tried it with the .NET Data Provider for Teradata
//Building connection string
TdConnectionStringBuilder builder = new TdConnectionStringBuilder();
builder.DataSource = "X";
builder.UserId = "Y";
builder.Password = "Z";
//Connecting to Teradata server
TdConnection connection = new TdConnection(builder.ConnectionString);
connection.Open();
//Calling OutParam Stored Procedure
using (TdCommand cmd = new TdCommand("",connection))
{
cmd.CommandText = "OutParam";
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 15;
cmd.UpdatedRowSource = UpdateRowSource.OutputParameters;
TdParameter param1 = new TdParameter();
param1.ParameterName = "PIN";
param1.Direction = ParameterDirection.Input;
param1.TdType = TdType.VarChar;
param1.Value = "a";
cmd.Parameters.Add((param1));
TdParameter param2 = new TdParameter();
param2.ParameterName = "POUT";
param2.Direction = ParameterDirection.Output;
param2.TdType = TdType.Decimal;
param2.Precision = 10;
param2.Value = 10;
cmd.Parameters.Add((param2));
TdParameter param3 = new TdParameter();
param3.ParameterName = "POUT2";
param3.Direction = ParameterDirection.Output;
param3.TdType = TdType.Decimal;
param3.Precision = 10;
cmd.Parameters.Add((param3));
cmd.ExecuteNonQuery();
//Displaying the returne parameters on console
Console.WriteLine("PIN = {0}", param1.Value.ToString());
if(param2.Value == null)
Console.WriteLine("POUT = null");
else if(DBNull.Value.Equals(param2.Value))
Console.WriteLine("POUT = DBNull");
else Console.WriteLine("POUT = {0}", param2.Value.ToString());
if (param3.Value == null)
Console.WriteLine("POUT2 = null");
else if (DBNull.Value.Equals(param3.Value))
Console.WriteLine("POUT2 = DBNull");
else Console.WriteLine("POUT2 = {0}", param3.Value.ToString());
} It works with the .NET Data Provider for Teradata but not "Microsoft .NET Data Provider for ODBC + ODBC Driver".
I suggest that you turn on ODBC TRACE; and see if you can gather additional information.
↧