locked
How can I convert decimal to comma in spanish..... RRS feed

  • Question

  • User-1213808446 posted

    In my database, I have a table called prices which has a field "Price" in it.. The datatype of this field is decimal..

    What I need to know is that, when a user enters a price of a particular thing, it may have decimal points.. But in Spanish, decimal is considered as a "," ie."Comma".. So I need to take the decimal point as comma in spanish when a user enters a price for a particular thing.....

    To be precise, If a user enters an amount 45825.256, It shoud be taken as 45825,256 in Spanish and should enter that amount in the database as 45825.256..

     

    How can I implement the above scenario in asp.net2.0?

     

    Thanking you in advance...

    Cheerss............. 

     

    Monday, April 9, 2007 2:40 PM

Answers

  • User-503940700 posted

    You need to use the CultureInfo class under System.Globalization namespace as shown in this post:

    http://geekswithblogs.net/vivek/archive/2007/01/24/104389.aspx

    Hope this helps,

    Vivek 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 9, 2007 5:37 PM

All replies

  • User-503940700 posted

    You need to use the CultureInfo class under System.Globalization namespace as shown in this post:

    http://geekswithblogs.net/vivek/archive/2007/01/24/104389.aspx

    Hope this helps,

    Vivek 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 9, 2007 5:37 PM
  • User-1213808446 posted

    Am extremely thankful to you.. That helped me alot...

    But I do have a small problem still... The problem is that the value entered is getting converted to spanish mode correctly... But when it gets inserted in the database, the value gets rounded.....

     

    For example, When I enter a value 1.23,235 its getting converted to 1,23.235 and finally when it enters the database the value gets rounded to 123.000    orelse that will be 124 if the decimal part is .523 etc...

     

    In the database SQL server 2000, the field "Price" has datatype decimal, Precision value is set to  19 and scale value is set to 6...

     

    Pls help me out to solve this.... Programatically its working well and proper value is getting till the insertion point to the database... Pls help me out...

    Thanks in advance..

    Cheerssssssssss..................... 

    Wednesday, April 11, 2007 9:58 AM
  • User83354550 posted

    Could you store the data as a string and convert back and too when sending/retrieving data from the database?

    Wednesday, April 11, 2007 10:41 AM
  • User-1213808446 posted

    No I cannot.. I have to store the price as decimal itself... Infact am getting the value properly till the insertion point to the database..But I don't know why its getting rounded off when it enters the database...

    Cheers........ 

     

    Wednesday, April 11, 2007 2:59 PM
  • User-503940700 posted

    No I cannot.. I have to store the price as decimal itself... Infact am getting the value properly till the insertion point to the database..But I don't know why its getting rounded off when it enters the database...

    Cheers........ 

     

    The reason for this might be the collation used in the DB. This article might shed some light on the problem: 

    http://msdn.microsoft.com/en-us/library/aa174903(SQL.80).aspx

    Hope this helps,

    Vivek 

     

    Wednesday, April 11, 2007 3:32 PM