Output parameter

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a stored procedure with an output parameter.

SqlCommand cmd = new SqlCommnad("ProcName", conn);
cmd.Parameters.Add("@myparam", SqlDbType.Int);
cmd.Parameters[0].Direction = ParameterDirection.Output;

Parameter param is an output parameter, but how can I read the returned value?

Thanks,

Lubomir
 
After you execute the command, you can access the value using
cmd.Parameters[0].value in your example.

If you are using ExecuteReader, you need to close the reader object
before accessing the output parameter.

Charles Zhang
http://www.speedydb.com
SpeedyDB ADO.NET Provider is the fastest ADO.NET provider over Wide Area
Network (WAN).
 
Thank you!

Lubomir


Charles Zhang said:
After you execute the command, you can access the value using
cmd.Parameters[0].value in your example.

If you are using ExecuteReader, you need to close the reader object
before accessing the output parameter.

Charles Zhang
http://www.speedydb.com
SpeedyDB ADO.NET Provider is the fastest ADO.NET provider over Wide Area
Network (WAN).


Hi,

I have a stored procedure with an output parameter.

SqlCommand cmd = new SqlCommnad("ProcName", conn);
cmd.Parameters.Add("@myparam", SqlDbType.Int);
cmd.Parameters[0].Direction = ParameterDirection.Output;

Parameter param is an output parameter, but how can I read the returned value?

Thanks,

Lubomir
 
Back
Top