473,398 Members | 2,403 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,398 software developers and data experts.

Problems with money, decimal numbers after migration to Framework 1.1

Hello,
after installing .net 1.1, ASP.NET works fine, but there is a problems with
extra zeros added to the numbers at the end.
In Sql 2000 SP3a there is for example a table with one column col1. Col1
is type of money ( four digits after decimal point).
Table has one row with data : col1=5.2.

In .Net 1.0 the following code
Response.Write("<input type=text size=3 maxlenght=4 name=test class=box
value='" + dt.DefaultView[k]["Col1"] + "' >");
produce input box with the value 5.2

the same code in .Net 1.1 produce box with the value 5.2000.
If I change the type of column to eg. decimal(18,9), I will get box with
value : 5.200000000

..Net 1.1 adds extra zeros at the end of the number. How to get rid of it
without rewriting the code in an application.

System has regional settings with 2 digits after the decimal point.

thanks in advance for help Artek

Nov 18 '05 #1
3 2171
Hi Artek,
Thanks for posting in the community!
From your description, you found that some certain numeric data type such
as Money and Decimal(SQLSERVER) 's value will be appended with zero in the
right of the decimal when retrieving them using ADO.NET component and
display them on ASP.NET web form, yes?
If there is anything I misunderstood, please feel free to let me know.

Based on your situation, I've done some research and a few tests on my
side, here is what I found:
1. As for the "Money" or "Decimal" or "Numeric" data type in the sqlserver,
the style how these type's value are displayed is controled by their
"Precision" and "Scale" Column Property. The "scale" is used to specify
number of digits to the right of the decimal point in a number.

Here is the detailed description in MSDN:
#Precision, Scale, and Length
http://msdn.microsoft.com/library/de...us/tsqlref/ts_
da-db_8rc5.asp

You can found them in the Table' Design View in the Enterprise Manager. For
the "Decimal" and "Numeric" the "precision" and "Scale" property can be
modified by user. But as fro the "Money" type, the two properties are fixed
to "19" and "4". That's why when you used the "Money" type, the output is
like: "5.2000" , when you use "decimal(19,9)", the output is like
"5.200000000".

2. In addtion, you may also have a try querying these datas from database
using the SQL QueryAnalyzer, you may found that the result queried by
QueryAnalyzer is also the same as which in ASP.NET page. So this behavior
is controled by the database server rather than modified in ADO.NET
components.

Please check out the preceding suggestion. If you feel anything unclear or
have any new findings, please feel free to post here.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #2
Thank you Steven for your reply,
you understood well .Net 1.1 appends zeros at the end, but .Net 1.0 did't do
it.
Is there any system setting to restore .Net 1.0 behavior without changing
the code?

regards Artek
Użytkownik "Steven Cheng[MSFT]" <v-******@online.microsoft.com> napisał w
wiadomo¶ci news:w9**************@cpmsftngxa07.phx.gbl...
Hi Artek,
Thanks for posting in the community!
From your description, you found that some certain numeric data type such
as Money and Decimal(SQLSERVER) 's value will be appended with zero in the
right of the decimal when retrieving them using ADO.NET component and
display them on ASP.NET web form, yes?
If there is anything I misunderstood, please feel free to let me know.

Based on your situation, I've done some research and a few tests on my
side, here is what I found:
1. As for the "Money" or "Decimal" or "Numeric" data type in the sqlserver, the style how these type's value are displayed is controled by their
"Precision" and "Scale" Column Property. The "scale" is used to specify
number of digits to the right of the decimal point in a number.

Here is the detailed description in MSDN:
#Precision, Scale, and Length
http://msdn.microsoft.com/library/de...us/tsqlref/ts_ da-db_8rc5.asp

You can found them in the Table' Design View in the Enterprise Manager. For the "Decimal" and "Numeric" the "precision" and "Scale" property can be
modified by user. But as fro the "Money" type, the two properties are fixed to "19" and "4". That's why when you used the "Money" type, the output is
like: "5.2000" , when you use "decimal(19,9)", the output is like
"5.200000000".

2. In addtion, you may also have a try querying these datas from database
using the SQL QueryAnalyzer, you may found that the result queried by
QueryAnalyzer is also the same as which in ASP.NET page. So this behavior
is controled by the database server rather than modified in ADO.NET
components.

Please check out the preceding suggestion. If you feel anything unclear or
have any new findings, please feel free to post here.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #3
Hi Artek,
Thanks for your followup. As for the "System setting" you mentioned, I
haven't found any ideas on it. But I think you may have a try using
different Data Providers to connect the SQLServer to see whether the result
remains the same. Also, you may also try this on a machine which has only
.NET 1.0 installed to confirm whether this problem does occurs due to the
1.1's internal mechanism. If it does behaviors like so, I think we need to
manually do some formatting on the output datas into our custom styles.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

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....
2
by: Brian van den Broek | last post by:
Hi all, I guess it is more of a maths question than a programming one, but it involves use of the decimal module, so here goes: As a self-directed learning exercise I've been working on a...
1
by: Jason Szotak | last post by:
Recently we upgraded the .Net Framework to v1.1. All of a sudden all of our queries run through .Net pages began showing all 4 of the decimal places for the money data type. Queries run through asp...
9
by: MDoyle | last post by:
Here is the easiest question you’ll get all day from a complete newbie. I installed Visual Studio on my laptop last night and have been tryin to write my very first C# programs this morning. I’m...
6
by: cj | last post by:
I have a comma delimited file with 2 numeric columns. The first is just a decimal number that seems to have a max of 1 decimal place. The last column is money BUT very tiny increments of money. ...
3
by: DustWolf | last post by:
Hello, I am wondering, what is the standard for including decimal numbers in XML code? What determines what is the decimal delimiter and what can be the grouping symbol? I have just realized...
4
by: Ronald S. Cook | last post by:
We're designing the data model for a project. The app will be in .NET, the database will be in SQL Server 2005. I'm a little confused on type conversion between the two and which I should...
3
by: Stephan Diehl | last post by:
Hi lazyweb, I'm wondering, if there is a usable money data type for python available. A quick search in pypi and google didn't convey anything, even though the decimal data type seemed to be...
1
by: =?Utf-8?B?dHRocm9uZQ==?= | last post by:
Hi, I am querying sql server and loading the resulting data into Excel. For character and integer data types, it's working well, but when I pull decimal data and attempt to load it into Excel...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.