473,654 Members | 3,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Return Decimal values problem !!!

1 New Member
Hi,
I have a stored procedure that executed in SQL Server 2000 that returns a decimal SUM value, the stored procedure executed successfully in Query Analyzer and returns the correct value, but when calling it from ASP.Net (VB) Page it always returns ZERO !!!

I'm sure that my VB.net code is true because i used it before successfully.

my stored procedure code is:

----------------------------------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE [spr_Total]
  2. (
  3.     @vchrClientNo varchar(50),
  4.     @Total decimal(18,3) OUTPUT
  5. )
  6. AS
  7. DECLARE
  8.     @Total decimal(18,3)
  9.  
  10. BEGIN
  11.     SELECT @Total = SUM(dcOutstandingBalance) 
  12.                 FROM bl_Accounts 
  13.                 WHERE vchrClientNo = @vchrClientNo
  14. END
  15.  
  16. GO
  17.  
----------------------------------------------------------------------------------------------

my .net call function:

----------------------------------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1.  Public Function GetTotalOutstandingBalance(ByVal vchrClientNo As String) As Decimal
  2.         Dim Params(1) As SqlParameter
  3.         Params(0) = New SqlParameter("@vchrClientNo", vchrClientNo)
  4.         Params(0).SqlDbType = SqlDbType.NVarChar
  5.         Params(1) = New SqlParameter("@Total", 0)
  6.         Params(1).SqlDbType = SqlDbType.Decimal
  7.         Params(1).Direction = ParameterDirection.Output
  8.         SqlHelper.ExecuteScalar(connectionString, CommandType.StoredProcedure, "spr_Total", Params)
  9.         Return Params(1).Value
  10.     End Function
  11.  
----------------------------------------------------------------------------------------------

Any help will be appriciated.

Regards,
Ishaq
Jan 22 '08 #1
1 1806
Plater
7,872 Recognized Expert Expert
You declare @total twice in your SQL procedure. Which means the output value is never getting populated because the code uses the more local version of the variable instead.
Jan 22 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
4520
by: Phil Powell | last post by:
My first time working with a PHP class, and after 6 hours of working out the kinks I am unable to return a value from the class, so now I appeal to the general audience what on earth did I do wrong this time? This is the code the retrieves the values: if (($hasRegistered || $hasPreRegistered) && !empty($uplinenumber)) { // CHECK TO SEE IF UPLINE NUMBER IS A VALID NUMBER $regNumberGenerator = new RegNumberGenerator($uplinenumber,...
17
6135
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number. "Decimal Number" sometimes serves to distinguish Base 10 numbers, eg "15", from Base 2 numbers, Eg "1111". At other times "Decimal Number" serves to differentiate a number from an integer. For the rest of this post I shall only use either...
687
23319
by: cody | last post by:
no this is no trollposting and please don't get it wrong but iam very curious why people still use C instead of other languages especially C++. i heard people say C++ is slower than C but i can't believe that. in pieces of the application where speed really matters you can still use "normal" functions or even static methods which is basically the same. in C there arent the simplest things present like constants, each struct and enum...
10
8120
by: Paul Sullivan | last post by:
decimal d; d = 1.1M OR d= (decimal) 1.1 Discussioon
15
1550
by: Bernard Bourée | last post by:
I have the following code: Dim mVar As New Variable() mVar.NomVal = "Test" ==> this line return a NomVal ="Test" mVar.oVal = 10D ====> but this one return a oVal= NOTHING !!!! What is wrong ?
0
1725
by: bunty.gopal | last post by:
I am trying to use the PreparedStatement's addBatch to load data in an ETL-like process into a table. There is a single prepared statement. The parameters are set on it and prepStmt.addBatch() is called. Then the next iteration of setting the params and adding to batch begins. Finally after setting the batch of 2 to 2000 rows, the prepStmt.executeBatch() is called. If the last row contains a null value for a particular DECIMAL field,...
11
2238
by: Pieter | last post by:
Hi, I'm having some troubles with my numeric-types in my VB.NET 2005 application, together with a SQL Server 2000. - I first used Single in my application, and Decimal in my database. But a Single with value 4.475 was converted to a Decimal with value 4.4749999999999996D. So after inserting and selecting it from the database I got another value than the original!
13
23257
by: Gregor =?UTF-8?B?S292YcSN?= | last post by:
Hi! Let's have a data of type DECIMAL(6, 2) and with value 0.01. How can I convert this one into a "pretty" CHAR? I've tried VALUES(CHAR(DECIMAL(0.01, 6, 2))) and I get 0000.01 which is not nice.
5
1294
by: =?Utf-8?B?THVpZ2k=?= | last post by:
Hi all, I have a collection (an array for example) of decimal values. I need to round them and take care of the roundings. For example, if I have decimal a = 10.50m should became 10 and if
0
8372
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8814
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8706
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8475
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5621
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4293
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2709
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1915
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1592
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.