473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Decimal value 0.00 becomes 0 in ASP.NET 1.1

Hi,
I am in big trouble for the last 10 days and not got any solution in the web.
My problem is : I have a project in .NET 1.1 version, which I have transfered to .NET 2.0 version , almost all are ok except one decimal value problem, it is like ...from my DataBase (Sql Server 2005) I am retreiving some records containg decimal value 0.00 , which is being stored into DataSet via SQL DataAdapter and when I am fetching that data (using DataSet object) 0.00 value becomes 0 in .NET 1.1 and in .NET 2.0 it remain same and I have done some logical calculation based on that value, which is not working properly in new .NET version due to this 0 problem.

Please help me
Apr 5 '07 #1
7 2715
channaJ
67
Hi,
I am in big trouble for the last 10 days and not got any solution in the web.
My problem is : I have a project in .NET 1.1 version, which I have transfered to .NET 2.0 version , almost all are ok except one decimal value problem, it is like ...from my DataBase (Sql Server 2005) I am retreiving some records containg decimal value 0.00 , which is being stored into DataSet via SQL DataAdapter and when I am fetching that data (using DataSet object) 0.00 value becomes 0 in .NET 1.1 and in .NET 2.0 it remain same and I have done some logical calculation based on that value, which is not working properly in new .NET version due to this 0 problem.

Please help me
Hi Sukantha,

As far as I understand, this can not be a problem. What ever the logical calculation you are performing can not be affected by this. If you can post the particular code segment, I might be able to help you.
Apr 6 '07 #2
shweta123
692 Expert 512MB
Hi,

Can you convert the value from Dataset using cdbl function ? So that it will get converted into double.
Apr 6 '07 #3
Hi Sukantha,

As far as I understand, this can not be a problem. What ever the logical calculation you are performing can not be affected by this. If you can post the particular code segment, I might be able to help you.
Hi channaJ
Thank you for your reply.
Code in .NET 1.1
decimal d1= Convert.ToDecimal(ds.Tables[0].Rows[0]["AEMSalBillOtherCharges"]);
"AEMSalBillOtherCharges" is a decimal(18,2) type column in my table and the default value is set to 0.
When I am checking (if(d1.ToString()=="0")) is ok for .NET 1.1 version but same checking is not working in .NET 2.0 because d1.ToString() returns 0.00.
I can change the code but for that I have to change more than 25 areas(web forms), which is a tested module and working properly.
I m looking for such solution by that I dont need to change any code and can work in .NET 2.0 version.
Apr 6 '07 #4
Re: Decimal value 0.00 becomes 0 in ASP.NET 1.1
--------------------------------------------------------------------------------

Quote:
Originally Posted by channaJ
Hi Sukantha,

As far as I understand, this can not be a problem. What ever the logical calculation you are performing can not be affected by this. If you can post the particular code segment, I might be able to help you.


Hi channaJ
Thank you for your reply.
Code in .NET 1.1
decimal d1= Convert.ToDecimal(ds.Tables[0].Rows[0]["AEMSalBillOtherCharges"]);
"AEMSalBillOtherCharges" is a decimal(18,2) type column in my table and the default value is set to 0.
When I am checking (if(d1.ToString()=="0")) is ok for .NET 1.1 version but same checking is not working in .NET 2.0 because d1.ToString() returns 0.00.
I can change the code but for that I have to change more than 25 areas(web forms), which is a tested module and working properly.
I m looking for such solution by that I dont need to change any code and can work in .NET 2.0 version.

--------------------------------------------------------------------------------
Apr 7 '07 #5
channaJ
67
Re: Decimal value 0.00 becomes 0 in ASP.NET 1.1
--------------------------------------------------------------------------------

Quote:
Originally Posted by channaJ
Hi Sukantha,

As far as I understand, this can not be a problem. What ever the logical calculation you are performing can not be affected by this. If you can post the particular code segment, I might be able to help you.


Hi channaJ
Thank you for your reply.
Code in .NET 1.1
decimal d1= Convert.ToDecimal(ds.Tables[0].Rows[0]["AEMSalBillOtherCharges"]);
"AEMSalBillOtherCharges" is a decimal(18,2) type column in my table and the default value is set to 0.
When I am checking (if(d1.ToString()=="0")) is ok for .NET 1.1 version but same checking is not working in .NET 2.0 because d1.ToString() returns 0.00.
I can change the code but for that I have to change more than 25 areas(web forms), which is a tested module and working properly.
I m looking for such solution by that I dont need to change any code and can work in .NET 2.0 version.

--------------------------------------------------------------------------------

Hi Sukantha,

Sorry for the late responce.(I didn't log in to the site during the weekend)

What you have done here is not acceptable. Why are you converting the decimal to a string and compaire it as a string? THIS IS NOT A GOOD PRACTICE AT ALL.

And the other thing is if d1 is a decimal it will definitely return the value 0.(not 0.00)

What you can do here is use the condition
Expand|Select|Wrap|Line Numbers
  1. if(d1 == 0) 
instead of
Expand|Select|Wrap|Line Numbers
  1. (if(d1.ToString()=="0")) 
Apr 10 '07 #6
Hi Sukantha,

Sorry for the late responce.(I didn't log in to the site during the weekend)

What you have done here is not acceptable. Why are you converting the decimal to a string and compaire it as a string? THIS IS NOT A GOOD PRACTICE AT ALL.

And the other thing is if d1 is a decimal it will definitely return the value 0.(not 0.00)

What you can do here is use the condition
Expand|Select|Wrap|Line Numbers
  1. if(d1 == 0) 
instead of
Expand|Select|Wrap|Line Numbers
  1. (if(d1.ToString()=="0")) 
Hi channaJ,
Yes d1 returns 0 in .NET 1.0 & 1.1 but in .NET 2.0 it returns 0.00.
I have checked this issue and got the same result.
Apr 10 '07 #7
channaJ
67
Hi channaJ,
Yes d1 returns 0 in .NET 1.0 & 1.1 but in .NET 2.0 it returns 0.00.
I have checked this issue and got the same result.
The problem with your code is that you are trying to compaire decimal values by converting them to strings. Just go through your code and eleminate this first.

I'm also using .Net 2.0 and I my self checked this. You should be able to compaire it as a decimal.
Apr 10 '07 #8

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

Similar topics

17
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....
17
by: Rob Oldfield | last post by:
From the documentation about Decimal.Round.... "When d is exactly halfway between two rounded values, the result is the rounded value that has an even digit in the far right decimal position. For...
4
by: spebola | last post by:
I am using vb.net 2003 professional and I get the following results when using the round method: dim Amount as decimal = 180.255 Amount = Amount.Round(Amount, 2) Amount now contains 180.25. ...
3
by: Matt | last post by:
Anybody noticed that SQL Server rounds up if the value is half way between two rounded values, but C#'s Decimal.Round(Decimal,Int32) rounds to nearest even number? >From MSDN: "When d is exactly...
4
by: Ryan Liu | last post by:
Is there a good reason that Decimal does not have Ceiling() method, only Math class has? Thanks!
11
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...
1
by: Andy Jenkins | last post by:
I'm thinking this ought to be easy (just not for me - lol). Field Price has values like this: 12500 9999 12999 105099 What's happened is that the person who originally populated it...
4
by: Gary Wessle | last post by:
Hi how can I return 0.0002 from 0.00015 and 0.0002 from 0.00014 Example: double myRound(double myNum, int precision); myRound(0.00015, 4); //should return 0.0002 myRound(0.00014, 4);...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.