I need to get the value returned from a stored procedure in my Sql Server db.a This store procedure using a return statement to return a value back to the app.
I need to retrieve this value in C#. How do i get this value?
Note:
I also know i can use a output variable.
What is don't know is how to retrieve the value returned from a return statement in my sp.
How do i get it done? I am avoid make a lot of change.
Update :
I'm using SQLHelper .
Add a parameter to the query using ParameterDirection.ReturnValue
for the paremeder Direction
property.
See this question .
Set your return parameter's Direction
property to ParameterDirection.ReturnValue
, and after you execute your command get return parameter's value like that :
SqlParameter myReturnParam = command.Parameters.Add("@MyReturnValue",
SqlDbType.Int);
myReturnParam.Direction = ParameterDirection.ReturnValue;
// Execute your Command here, and get the value of your return parameter :
int myReturnValue = (int)command.Parameters["@MyReturnValue"].Value;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.