Skip to main content
December 7, 2006
Question

SQL Insert using comma as decimal

  • December 7, 2006
  • 3 replies
  • 2159 views
How to insert a number using comma as a decimal separator?
I'm in Brazil, here the number format is "1.000,00" or "1000,00"
I´m trying to use the DW default ASP Insert/Update behavior to insert a comma separated number in SQL
Insert Exemples:
"10,99" as numeric - [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '99'.
"10,99" as text (work with ms access db) - [Microsoft][ODBC SQL Server Driver][SQL Server]Error converting data type varchar to numeric.
"10.99" as numeric - works ok
"10.99" as text - works ok
This topic has been closed for replies.

3 replies

Inspiring
December 7, 2006
Write your own insert using DW's command object, not the built-in insert
record behavior. It's shorter and cleaner, and you can do your own
validation and processing before inserting the record.

"oteacher" <webforumsuser@macromedia.com> wrote in message
news:el9g54$d5q$1@forums.macromedia.com...
> Ok, i've imagined that, but how do i raplace a form field server side with
> the
> DW Update behavior?
> I can't alter the fields after they are submitted.
> Maybe a sort of Form Validation Routine?
> I'd like to make this transparent to the final user.
>


December 7, 2006
Ok, i've imagined that, but how do i raplace a form field server side with the DW Update behavior?
I can't alter the fields after they are submitted.
Maybe a sort of Form Validation Routine?
I'd like to make this transparent to the final user.
Inspiring
December 7, 2006
"oteacher" <webforumsuser@macromedia.com> wrote in message
news:el7n0e$7an$1@forums.macromedia.com...
> How to insert a number using comma as a decimal separator?

It's not going to work. You'll have to do a find and replace.

myNumber = Replace(Replace(Request.Form("numberField"),".",""),",",".")

The inner replace removes all decimal points (because you indicated that
might be used as a thousands separator), then the outer replace replaces all
commas with decimal points. Using FormatNumber when you write the number to
the screen will format it as you're used to, but the number must be inserted
with a regular decimal point.