Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rajesh Kumar JhaRank #9,215 · 209 reputationPosted Nov 15, 2013, 6:00 AM EST
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
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Nov 15, 2013, 11:10 PM EST
Do you have DataLayer?
While asking questions, please mention your development environment, so that, it will be easy to give the solution for you.
anant tomar41 reputationPosted Nov 15, 2013, 11:28 PM EST
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Nov 16, 2013, 1:52 AM EST
Can you show us the code? In that we have to make some changes to get the output value.