Friday, February 10, 2012

convert data to currency

I have a column - datatype 'money' and my price variable is (for instance)
8450
how do I put this value into the money column without getting this error?

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 'db196009544.dbo196009544.vehicles', column 'price'. Use the CONVERT function to run this query.

ASP VBScript
I am using this syntax:

price = Upload.Form("price") '--this gives 8450--

SQL="UPDATE vehicles SET price='" & price & "' WHERE id=" & request.queryString("linkID") & ""

Thanks
markDo you define the variable as a daatype...sounds like it's defined as char if you are|||not sure!
I have tried using cCur() and various others when estting the variables but to no avail.

I suspect it has to be done in the SQL string, but can't make that work either.|||I mean it lloks like vb, and I'd ratyher keep my hands clean, buit can you do?

price = Upload.Form(price)

Also, you'd be way better off using stored procedures|||removing the single quotes from the price variable apears to have solved that but now the datetime variable is playing up in the same fashion, so I can't be sure if all is well with the price.
see my next post!

No comments:

Post a Comment