i need to get a value from a Sp

hi there in the sp i have this code  :

ALTER PROCEDURE dbo.MelayUpdateTotalquantity
(
            @ProKey varchar(50),
            @Total money output
            
)
AS
      SET NOCOUNT ON
      select Sum(Kamot) as Total from MelayActions where CodeParit=@ProKey
      RETURN

in the Form i have this code :

public bool GetSumTotal(string ProKey)
            {
                  SqlParameter[] sp = new SqlParameter[2];

                  sp[0] = new SqlParameter("@ProKey",SqlDbType.VarChar,50);
                  sp[0].Value = ProKey;

                  sp[1] = new SqlParameter("@Total",SqlDbType.Money);
                  sp[1].Direction=ParameterDirection.Output;

                  SqlDataReader dr = SqlHelper.ExecuteReader(strCnn,CommandType.StoredProcedure,"MelayUpdateTotalquantity",sp);
                  
                  decimal sum =Decimal.Parse(sp["@Total"].Value.Tostring());
                  
                  return true;            
            }
i cant get the Total Value whit this line : decimal sum =Decimal.Parse(sp["@Total"].Value.Tostring());
how can i pull out the Total Value From the Sp to the sum variable ?

thanks ...
Tech_MenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gbzhhuCommented:
Try changing the sp like this

     SET NOCOUNT ON
     select Set @Total = Sum(Kamot) from MelayActions where CodeParit=@ProKey
     RETURN @Total
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tech_MenAuthor Commented:
its o.k but i needed to remove the set word and its working good !!!

thanks .
0
gbzhhuCommented:
Glad it is working.  I didn't test the syntax, sorry
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.