Reading output parameter from stored procedure......

G

Gish Smith

In my ADO.Net coding I am using SQLCommand and SQLParameter to run stored
procedure. Can any one advice me how to read the output parameter from a
stored procedure. I am using SQL Server 2000.
Gish Smith
 
G

Gish Smith

thanks

Anatoly said:
It's easy one:

SqlCommand cmd = new SqlCommand("sp_...", myConnection);
cmd.Parameters.Add("@myInputParam", SqlDbType.Char, 20).Value =
"myStringValue";
cmd.Parameters.Add("@myOutputParam", SqlDbType.Int).Direction =
ParametersDirection.Output;
myConnection.Open()
cmd.ExecuteNonQuery()
//here it come:
int ReturnValue = cmd.Parameters["@myOutputParam"].Value;
myConnection.Close();

HTH

Gish Smith said:
In my ADO.Net coding I am using SQLCommand and SQLParameter to run stored
procedure. Can any one advice me how to read the output parameter from a
stored procedure. I am using SQL Server 2000.
Gish Smith
 
A

Anatoly

It's easy one:

SqlCommand cmd = new SqlCommand("sp_...", myConnection);
cmd.Parameters.Add("@myInputParam", SqlDbType.Char, 20).Value =
"myStringValue";
cmd.Parameters.Add("@myOutputParam", SqlDbType.Int).Direction =
ParametersDirection.Output;
myConnection.Open()
cmd.ExecuteNonQuery()
//here it come:
int ReturnValue = cmd.Parameters["@myOutputParam"].Value;
myConnection.Close();

HTH
 

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