?
Solved

i need to get a value from a Sp

Posted on 2006-04-07
3
Medium Priority
?
264 Views
Last Modified: 2012-05-05
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 ...
0
Comment
Question by:Tech_Men
  • 2
3 Comments
 
LVL 12

Accepted Solution

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

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

Author Comment

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

thanks .
0
 
LVL 12

Expert Comment

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

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