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,249 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Save ms data to server side. 19 64
Session on Html 8 55
JS to redirect to prev page 8 47
Get Pop-Up Or Div Info Box From JQuery DataTable Cell in ASP 7 38
Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

710 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