Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using CONVERT for Varchar to Money

Status
Not open for further replies.

jimny

Technical User
Oct 18, 2002
52
0
0
US
I am doing an insert on an ASP page, and not able to insert a value in to a column with a datatype of 'Money'.

I have tried several different ways of doing it, but get the same result with all.

Here is the ASP part of geting the variable value:

ResCost = request("Reservation_Cost")
'** I figure thatconverting it to a number first is best**
dim insResCost
insResCost = cdbl(ResCost)

Here is the SQL statement:

sql= "SET NOCOUNT ON " & _
"INSERT INTO tblCCReserve(Event,BillName,ChargeAmount,CreditCard,CreditCardName," & _
"CreditCardCompany,CreditCardNum,CreditCardExpMo,CreditCardExpYear,ReservationDate," & _
"eCC) VALUES('"&txtEvent&"','"&CCname&"','CONVERT(money,"&insResCost&")','"&btnCard&"','"&CCname&"'," &_
"'"&CCcompany&"','"&EncryptAcctNo&"','"&CCExpMo&"','"&CCExpYear&"','"&ResDate&"','1')" & _
" SELECT @@IDENTITY as RecNum"

And it always returns:

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

[Microsoft][ODBC SQL Server Driver][SQL Server]Disallowed implicit conversion from data type varchar to data type money, table 'WCACredit.dbo.tblCCReserve', column 'ChargeAmount'. Use the CONVERT function to run this query.

What am I doing wrong?

Thanks for any
 
Try removing the single quotes from around your Convert statement and putting them only around the string.

old:
'CONVERT(money,"&insResCost&")'

new:
CONVERT(money,'"&insResCost&"')
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top