Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 String to currency

Author  Topic 

alxtech
Yak Posting Veteran

66 Posts

Posted - 2007-09-28 : 11:16:10
Hello forum,
I am quering a datebase table from an asp page, comparing values that the user input in a form, value is a string 1000000 and the field in the database that i am compparing from is a currency type, i am getting an error saying that i need to convert to currency, type mistmatch. i am using the following to convert but it does not work, any suggestions.

here is my query:
"SELECT STotalAllocation FROM tabletoquery where STotalAllocation >='" & CCur(Session("plusMillion")) & "' "

'Session("plusMillion") is equal to 1000000

this is the error:
Error Type:
Microsoft OLE DB Provider for SQL Server (0x80040E07)
Disallowed implicit conversion from data type varchar to data type money, table 'SiteDetail7CMaster', column 'STotalAllocation'. Use the CONVERT function to run this query.
search_report.asp, line 136


khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-09-28 : 11:21:34
[code]"SELECT STotalAllocation FROM tabletoquery where STotalAllocation >= " & CCur(Session("plusMillion"))[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

alxtech
Yak Posting Veteran

66 Posts

Posted - 2007-09-28 : 11:30:20
thanks you are the MAN!!!!
why in the world the single quotations ' will kill the query.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2007-09-28 : 14:01:39
Are you sure they are a man?


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-09-28 : 14:32:48
"why in the world the single quotations ' will kill the query."

Because, as the error message infers, implicit conversion from Character String to Money is not supported.

Kristen
Go to Top of Page
   

- Advertisement -