By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,369 Members | 1,188 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,369 IT Pros & Developers. It's quick & easy.

Problems with money, decimal numbers after migration to Framework 1.1

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.