Support decimal symbol "," (comma) in ASP pages

Hi all,
I am on a project about Ecommerce in ASP and MSSQL Server. I coded a lot of pages.

Now, we want to support users to choose their own decimal symbol ("." dot or "," comma) in displaying and entering number (also currency).
If they choose "," and when enter number "123,34", then before insert into db, we must convert this number into "123.34" for MSSQL "understanding" this number. Because I coded a lot of pages, it's very hard to review all pages and do the conversion.

Do you have any experiences to do this with a minimum effort?
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

jcrumbleConnect With a Mentor Commented:
Do you want to retain the format of the number the user indicated after they have inserted it into the DB?  Based on your scenario, if I understand correctly) you want to retain the format the only thing I can suggest is to go into a character based field and if you have to do calculations change the format to numeric at that time.  That would eliminate the need for an indicator but give you the ability to display the information how the user entered it.  

I have dealt with a Databases that does allow different decimal symbols for numeric formats, but unfortunately never in SQL Server.  Not knowing of a way to allow different decimal symbols in MSSQL, about the best suggestion I have is to create two views where one view deals with a dot format and the other deals with a comma format.  That way your base information is still contained in the same table but the way it is displayed can be controlled by the view.  I think aside from having an MSSQL format, this could require fewer changes in your SPs and ASP SQL.

Also,  based on John-Doe's message I thought I would also mention a text editor you might find useful.  The name of it is editplus and it can be found at . This editor has all the functions you could imagine (and some you wouldn't have ever thought of) as well as, search capabilities for lines of code through folders and subfolders (extremely handy) and syntax files for many many languages that will not only color code your work but also save you looking up syntax because with a double click it inserts into your code.  Check it out (you too John-Doe). I think you'll be pleased with it.

Good Luck,
I had to do basically the same thing.  What I wound up doing was to:

1. Add a column to the table to indicate which format the user had selected assuming existing data is currently formatted using a "." dot, I loaded the indicator column with a "d" for dot.

2. I then changed my SQL code so that instead of just outputting the field as is I had a case statement that checked the value in the indicator column and replced the comma if the indicator was a "C".
For Example:
case Indicator when "C"  then REPLACE(Cast(advance AS nvarchar),'.',',') else field end

3. I then added Validations to my ASP page to check for the existance  of the ',' prior to insert/update and set a variable to load into the indicator column for each record I had going into the table.  Depending on your DB design you might need to either have a multi-part indicator for each field you want to allow this for or multiple indicators.  You could also set the variable to pass in JavaScript if your more comfortable with that.

Sorry to say but that's about as easy as I can think of.

Hope this helps and good luck,
John-DoeConnect With a Mentor Commented:
If you are going to edit the .asp files i can strongly recomend textpad for multiple file edit. (

It supports ie doing replacement using regular expressions in all open documents and a lot of other powerfull functions...
- Do a fast search trough all .asp files in a folder and all subfolders (also supportive with regexp)
- and so forth and so forth..
pnttAuthor Commented:
Thanks jcrumble and John-Doe,

To jcrumble: I think your solution is rather complicated for me. Because in my project, there are some pages with Stored Procedures and some with InLine SQL.

I thought of using the Conversion functions for display numbers (depend on the format which the users chose) and then with the numbers inputed from users (no matter how they are formatted), the function will convert them into numbers with "dot" symbol and record into DB. This way will take a lot of time and carefulness as I indicated.

I want a solution that MSSQL understands multi-formatted numbers depending a indicator we set up at first (i.e: "dot" or "comma"). Is there that solution?
All Courses

From novice to tech pro — start learning today.