Type Mismatch in MySQL

Posted on 2006-04-04
Last Modified: 2008-02-01

I am in the process of migrating from Access to MySQL and the following is a snippet of code that used to work but now doesn't.

Do Until objRec.EOF
  curRCValTotal = curRCValTotal + objRec.Fields("fldRCVal")

I get the following error:

Microsoft VBScript runtime (0x800A000D)
Type mismatch

MySQL doesn't have a currency datatype like Access did so it is set to type 'decimal(10,2)' I have checked the data type of the recordset field ('fldRCVal') and the result is '14' or VB decimal. I have tried converting the datatype to currency like so:

CCur(curRCValTotal) = CCur(curRCValTotal) + CCur(objRec.Fields("fldRCVal"))

but I get the following error:

Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'CCur'

Any suggestions?

Question by:leefirth
    LVL 48

    Accepted Solution


    curRCValTotal = CCur(curRCValTotal) + CCur(objRec.Fields("fldRCVal"))
    LVL 11

    Expert Comment

    Often you will get this error if the fldRCVal field is set to NULL
    To overcome, try the following:

    curRCValTotal = CCur("0" & Trim(curRCValTotal)) + CCur("0" & Trim(objRec.Fields("fldRCVal")))

    That adds a zero to the beginning of the value. So, 1.45 becomes 01.45 and is translated correctly. NULL becomes "0" and translates correctly.
    LVL 48

    Expert Comment

    by:Ryan Chong
    I think Trim(curRCValTotal) may error too if curRCValTotal contains NULL value, so maybe this better...

    curRCValTotal = CCur("0" & Trim("" & curRCValTotal)) + CCur("0" & Trim("" & objRec.Fields("fldRCVal")))

    or maybe...

    curRCValTotal = 0
    if isnumeric(objRec.Fields("fldRCVal")) then
        curRCValTotal = curRCValTotal + objRec.Fields("fldRCVal")
    end if


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
    Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    754 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

    14 Experts available now in Live!

    Get 1:1 Help Now