inserting amount with comma

Whing Dela Cruz
Whing Dela Cruz used Ask the Experts™
on
Hi, Experts, I've got problem Inserting data on sqlserver 2008 using ASP or vbscript language. My problem here is when the amountA is has a comma then it would not save the Data. A message says; "There are fewer columns in the insert..." This maybe because of the comma in the amountA. What is the solution to handle the comma within the amountA? Any help please!

   ename = "John"
   amountA = "10,000.00"
   
   con.execute("Insert into zPhone(eName,AmountA) values('" & ename & "'," & amountA & ")")
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Web Ninja at large
Commented:
"10,000.00" is not a valid data format for any kind of numerical column in sql server. The correct format would be "10000.00", so you could do a simple find/replace on the variable amountA:

amountA = "10,000.00"
amountA = Replace( ",", "" )

con.execute("Insert into zPhone(eName,AmountA) values('" & ename & "'," & amountA & ")")

Author

Commented:
Thanks a lot Big Monty, this code works amountA = Replace( amountA ,",", "" )

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial