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,213 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

932 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now