4
Answers

How to call STORED PROCEDURE with OUTPUT parmeter in mvc4

anant tomar

anant tomar

11y
1.8k
1
How to call STORED PROCEDURE with OUTPUT parmeter in  mvc4
Answers (4)
0
Jaganathan Bantheswaran
NA 21.9k 2.2m 11y
How are you executing the SPs now in your project?
Can you show us the code? In that we have to make some changes to get the output value.
0
anant tomar
NA 11 4.2k 11y
i have data access layer business layer and in UI layer(In UI layer  i have Model View Contoler)so i want to know how to use output variable in my project Model ,View,Controller or DAL ,BAL Plz give me code 
0
Jaganathan Bantheswaran
NA 21.9k 2.2m 11y
Have you tried?

Do you have DataLayer?

While asking questions, please mention your development environment, so that, it will be easy to give the solution for you.
0
Rajesh Kumar Jha
NA 184 5k 11y
SqlCommand cmd = new SqlCommand("MyStoredProcedure", cn);
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