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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert in the SQL statement getting syntax error

Status
Not open for further replies.

Gatorajc

MIS
Mar 1, 2002
423
US
Im trying to put some information from a form into a database. This is the error message I am getting.

[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '('.

/HTMLpages/toolbars/credit_investigations/letterchoice.asp, line 51

This is the line I changed when it started to throw the error.

sqlString = "INSERT INTO CustInfo (ACSUserID, Department, Unit, LetterType, SubLetterType, AccountNumber, CAST (AccountBalance AS smallmoney), FirstName, "

I have put [] and "" and '' and they all throw errors.

I have to use CAST ( or CONVERT I was just trying CAST first) because It throws an error the following error.

[Microsoft][ODBC SQL Server Driver][SQL Server]Disallowed implicit conversion from data type varchar to data type smallmoney, table 'ToolBars.dbo.CustInfo', column 'AccountBalance'. Use the CONVERT function to run this query.

/HTMLpages/toolbars/credit_investigations/letterchoice.asp, line 51

Any ideas but my problem?
 
CAN YOU POST THE ENTIRE SQL STATEMENT

INSERT INTO CustInfo (ACSUserID, Department, Unit, LetterType, SubLetterType, AccountNumber, CAST (AccountBalance AS smallmoney), FirstName,

The cast is in the field list rather than the values list
i.e.
sql = "INSERT INTO Table1(AccountBalance) " & _
"VALUES(CAST(" & variable & " AS smallmoney))"
 
That was my problem I put it in the Fields instead of values. THANK YOU!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top