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

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

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

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…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

615 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