Output parameter

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
 
C

Charles Zhang

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).
 
G

Guest

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
 

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