Solved

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

Posted on 2004-08-25
4
1,607 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

623 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