odbc.net output parameter truncated to 256 bytes

L

LucaP

Hi,
I've an .NET application in C# who connects to a Sybase db through ODBC.NET data provider of the 1.1 Framework.

The code execute a simple stored procedure, GETOBJECT passing two parameters, an input ID and a output OBJECT. The ID field is a varchar(50), while the OBJECT is a VarBinary(7800).

Here is the code I use to add parametes and execute the stored procedure:

OdbcConnection conn = new OdbcConnection(strOdbcConnSybase);
OdbcCommand cmd = new OdbcCommand();

OdbcParameter id = new OdbcParameter();
id.Direction = ParameterDirection.Input;
id.OdbcType = OdbcType.VarChar;
id.Value = tbxKey.Text;
id.ParameterName = "@ID";
cmd.Parameters.Add(id);

OdbcParameter obj = new OdbcParameter();
obj.Direction = ParameterDirection.Output;
obj.OdbcType = OdbcType.VarBinary;
obj.Size = 7800;
obj.ParameterName = "@OBJECT";
cmd.Parameters.Add(obj);

cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "{call GETOBJECT (?, ?) }";

conn.Open();
cmd.ExecuteNonQuery();
byte[] outData = (byte[])cmd.Parameters[1].Value;
conn.Close();

Everything works fine with the ExecuteNonQuery, but where I try to retrieve the output parameter OBJECT its Value is truncated to 256 bytes, while on the db its value is 400 bytes.

Changing the Value property of the output parameter nothing changes, even if I set it to 100, the returned value is 255 (being on the db of 400 bytes). So it's clear that the Size property of the parameter has not been taken into account by the provider.

Any suggestions?

Bye

Luca
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top