i need to get a value from a Sp

Posted on 2006-04-07
Last Modified: 2012-05-05
hi there in the sp i have this code  :

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

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);

                  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 ...
Question by:Tech_Men
    LVL 12

    Accepted Solution

    Try changing the sp like this

         select Set @Total = Sum(Kamot) from MelayActions where CodeParit=@ProKey
         RETURN @Total

    Author Comment

    its o.k but i needed to remove the set word and its working good !!!

    thanks .
    LVL 12

    Expert Comment

    Glad it is working.  I didn't test the syntax, sorry

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now