Link to home
Start Free TrialLog in
Avatar of Tech_Men
Tech_MenFlag for Israel

asked on

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 ...
ASKER CERTIFIED SOLUTION
Avatar of gbzhhu
gbzhhu
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tech_Men

ASKER

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

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