i need to get a value from a Sp

Posted on 2006-04-07
Medium Priority
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
  • 2
LVL 12

Accepted Solution

gbzhhu earned 750 total points
ID: 16401985
Try changing the sp like this

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

Author Comment

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

thanks .
LVL 12

Expert Comment

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

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

850 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