How to call STORED PROCEDURE with OUTPUT parmeter in mvc4
How to call STORED PROCEDURE with OUTPUT parmeter in mvc4
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jaganathan BantheswaranPosted Nov 16, 2013, 6:52 AM
Can you show us the code? In that we have to make some changes to get the output value.
anant tomarPosted Nov 16, 2013, 4:28 AM
Jaganathan BantheswaranPosted Nov 16, 2013, 4:10 AM
Do you have DataLayer?
While asking questions, please mention your development environment, so that, it will be easy to give the solution for you.
Rajesh Kumar JhaPosted Nov 15, 2013, 11:00 AM
cmd.CommandType=CommandType.StoredProcedure;
SqlParameter parm=new SqlParameter("@pkid",SqlDbType.Int);
parm.Value=1;
parm.Direction =ParameterDirection.Input ;
cmd.Parameters.Add(parm);
SqlParameter parm2=new SqlParameter("@ProductName",SqlDbType.VarChar);
parm2.Size=50;
parm2.Direction=ParameterDirection.Output; // This is important!
cmd.Parameters.Add(parm2);
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
// Print the output value
Console.WriteLine(cmd.Parameters["@ProductName"].Value);
Console.ReadLine();
Ref:: http://stackoverflow.com/questions/3433694/how-to-run-the-stored-procedure-that-has-output-parameter-from-c