Solved

Disallowed implicit conversion from data type varchar to data type money, table 'OPICForms.dbo.Applications', column 'TotalCost'. Use the CONVERT function to run this query.

Posted on 2007-04-03
5
1,227 Views
Last Modified: 2008-01-09
Hello Everyone, I get the following error from an UPDATE statement from a variable of the datatype money called "TotalCost"

MY CODE:


            strSQL = "UPDATE Applications SET ProjCtry='" & fnNullIfEmpty(request.form("ProjCtry")) & "', "    'added fnNullIfEmpty(strThis)
            strSQL = strSQL & "Industry='" & fnNullIfEmpty(request.form("Industry")) & "', "   'added fnNullIfEmpty(strThis)
            strSQL = strSQL & "TotalCost=" & fnMakeBlank(request.form("TotalCost")) & ", "
            strSQL = strSQL & "OPICLoan=" & fnMakeBlank(request.form("OPICLoan")) & ", "
            strSQL = strSQL & "OPICName='" & fnNullIfEmpty(request.form("OPICName")) & "', "            
            strSQL = strSQL & "Description='" & fnNullIfEmpty(request.form("Description")) & "', "  'added fnNullIfEmpty(strThis)
            strSQL = strSQL & "New = " & fnNullIfEmpty(request.form("New")) & " "  'added fnNullIfEmpty(strThis)
            strSQL = strSQL & "WHERE PID=" & Session("UserID")
            'response.write(strSQL)
            objConn.Execute(strSQL)


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 'OPICForms.dbo.Applications', column 'TotalCost'. Use the CONVERT function to run this query.

0
Comment
Question by:Gemini532
  • 3
  • 2
5 Comments
 
LVL 13

Expert Comment

by:jmundsack
ID: 18846424
Does fnMakeBlank(request.form("TotalCost")) result in a currency value that includes a dollar sign or other currency identifier, or separating commas, etc., e.g., 2,300.23 instead of 2300.23?

The currency identified and comma, I think would cause the specified error.
0
 

Author Comment

by:Gemini532
ID: 18846481
THat is correct!  This is because this field can have a huge number, and they want to see it separated by commas, however, it's giving me an error during the UPDATE, how can I fix it without changing the databtype to varchar...  Or is there no way to leave the datatype as money?
It's money right now, but it's giving me an error....  Can you help?
0
 

Author Comment

by:Gemini532
ID: 18846490
Does this mean I have to change the datatype to varchar?
is this what the problem is here? If it contains commas, than it must be varchar?
0
 
LVL 13

Accepted Solution

by:
jmundsack earned 500 total points
ID: 18846506
Try this line for the total cost field:

            strSQL = strSQL & "TotalCost= CONVERT(money,'" & fnMakeBlank(request.form("TotalCost")) & "'), "

(Note the single-quote just after the word money, and the single-quote and end paren just prior to the final comma.)
0
 

Author Comment

by:Gemini532
ID: 18847033
Amazing, how did you know that?
hehe
Thank you!
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

823 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