Solved

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

Posted on 2004-08-25
4
1,601 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Uploading files to the web server has become common part of almost any kind of web application. People use different technologies to solve this, but regardless of the technology used, it is always useful to have some kind of progress indicator shown…
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…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now