Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Incorrect syntax near the keyword 'Convert'.

Posted on 2004-11-12
4
Medium Priority
?
1,549 Views
Last Modified: 2008-01-09
This is the initial error i get

Microsoft OLE DB Provider for SQL Server error ‘80040e07’

Disallowed implicit conversion from data type varchar to data type money, table ‘Corpweb.dbo.GoldsNum’, column ‘Sales’.  Use the CONVERT function to run this query.

/goldsweb/NumberGen.asp, line 29


and when i try to use the convert function i get the error that i put in the title of this question.

this is my string:

<% strSQLConvert = "Convert(numeric,'" & strSales & "')" %>

Please HELP!
Thanks,
Andrew

0
Comment
Question by:Ahelbling
  • 2
4 Comments
 
LVL 3

Expert Comment

by:djwillms
ID: 12572328
You could rewrite your sql like this:

select cast(sales as money) from Corpweb.dbo.GoldsNum

or, you could physically change/alter the data type of the sales column to money, permenately in the tables schema.
0
 

Author Comment

by:Ahelbling
ID: 12584196
okay but the data type in the table is already a money data type.
The problem is when i try to write a text box value of 125.25 for example, it can't because it is trying to write text to a money field. I need to convert it to money first and then write it to the field.
0
 

Author Comment

by:Ahelbling
ID: 12584939
so this is what i have tried and it isn't working either....

<% strSQL = "INSERT INTO GoldsNum(BegDate, EndDate, EmpName, Store, EmpPosition, Sales, Members, Sessions, Commission)" & _
   "VALUES('" & strBegDATE & "','" & strEndDate & "','" & strEmpName & "','" & strStore & "','" & strEmpPosition & "',CONVERT(money,'" & strSales & "'),'" & strMembers & "','" & strSessions & "','" & strCommissions & "');" %>

and the error i get is:

Microsoft OLE DB Provider for SQL Server error '80040e14'

Incorrect syntax near the keyword 'Convert'.

/goldsweb/NumberGen.asp, line 31.

Thanks!
0
 
LVL 3

Accepted Solution

by:
CAVcc earned 2000 total points
ID: 12610735
have you tried the FormatCurrency function?

The FormatCurrency function returns an expression formatted as a currency value using the currency symbol defined in the computer's control panel.

Syntax
FormatCurrency(Expression[,NumDigAfterDec[,
IncLeadingDig[,UseParForNegNum[,GroupDig]]]])

Parameter Description
expression Required. The expression to be formatted
NumDigAfterDec Optional. Indicates how many places to the right of the decimal are displayed. Default is -1 (the computer's regional settings are used)
IncLeadingDig Optional. Indicates whether or not a leading zero is displayed for fractional values:
-2 = TristateUseDefault - Use the computer's regional settings
-1 = TristateTrue - True
0 = TristateFalse - False
 
UseParForNegNum Optional. Indicates whether or not to place negative values within parentheses:
-2 = TristateUseDefault - Use the computer's regional settings
-1 = TristateTrue - True
0 = TristateFalse - False
 
GroupDig Optional. Indicates whether or not numbers are grouped using the group delimiter specified in the computer's regional settings:
-2 = TristateUseDefault - Use the computer's regional settings
-1 = TristateTrue - True
0 = TristateFalse - False
 

Example 1
document.write(FormatCurrency(20000))Output:$20,000.00

Example 2
document.write(FormatCurrency(20000.578,2))Output:$20,000.58

Example 3
document.write(FormatCurrency(20000.578,2,,,0))Output:$20000.58


0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Screencast - Getting to Know the Pipeline

577 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