Solved

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

Posted on 2004-08-25
4
1,603 Views
Last Modified: 2010-05-18
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?
0
Comment
Question by:pntt
  • 2
4 Comments
 
LVL 4

Expert Comment

by:jcrumble
ID: 11894079
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,
Jeff
0
 
LVL 1

Assisted Solution

by:John-Doe
John-Doe earned 100 total points
ID: 11897743
If you are going to edit the .asp files i can strongly recomend textpad for multiple file edit. (http://www.textpad.com)

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..
0
 

Author Comment

by:pntt
ID: 11900246
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?
0
 
LVL 4

Accepted Solution

by:
jcrumble earned 400 total points
ID: 11903396
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 www.editplus.com . 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,
Jeff
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question