Phoenix Design & Solutions

CRM, Development and Nonsense

By

ColdFusion, SQL and Invalid Parameter Binding

While working on a multi-option search function for a client, I kept encountering a ColdFusion error, ‘Invalid Parameter Binding’. ¬†After much googling, I had found no solution that worked for me. ¬†Then I noticed that I had coded my parameter as such:

WHERE 0 = 0 
<cfif isNumeric(oArgs.Item)>
AND o.OrderId LIKE '%<cfqueryparam value="#oArgs.Item#" cfsqltype="cf_sql_varchar" maxlength="100" />%'
<cfelse>
AND d.TransactionId LIKE '%<cfqueryparam value="#oArgs.Item#" cfsqltype="cf_sql_varchar" maxlength="100" />%'
</cfif>

Maybe a silly mistake, but the solution was profoundly simple, even if the error message was not very informative. Updating my code to remove the single quotes and include the % inside of the cfqueryparam tag was all that needed to be done.

WHERE 0 = 0 
<cfif isNumeric(oArgs.Item)>
AND o.OrderId LIKE <cfqueryparam value="%#oArgs.Item#%" cfsqltype="cf_sql_varchar" maxlength="100" />
<cfelse>
AND d.TransactionId LIKE <cfqueryparam value="%#oArgs.Item#%" cfsqltype="cf_sql_varchar" maxlength="100" />
</cfif>

Made the change and everything started working as expected.

7 Responses to ColdFusion, SQL and Invalid Parameter Binding

  1. Jorge says:

    It’s hard to find your website in google. I found it on 12 spot, you should build
    quality backlinks , it will help you to increase traffic.
    I know how to help you, just search in google – k2 seo tips

  2. Ricky says:

    I see a lot of interesting articles on your blog. You have to spend a lot of
    time writing, i know how to save you a lot of time,
    there is a tool that creates unique, SEO friendly articles in couple
    of minutes, just type in google – laranita’s free content source

  3. Evelyne says:

    I read a lot of interesting posts here. Probably you spend a lot of time writing, i know how to save
    you a lot of work, there is an online tool that creates unique, SEO friendly
    posts in seconds, just type in google – laranitas free content source

  4. weight loss says:

    Awesome posts you post here, i have shared this article
    on my fb

  5. 95Weldon says:

    Hi blogger, i must say you have hi quality posts here.
    Your page can go viral. You need initial traffic
    boost only. How to get it? Search for; Mertiso’s tips go viral

  6. 86Bell says:

    I see you don’t monetize your page, don’t waste your traffic,
    you can earn additional bucks every month because you’ve got high quality content.
    If you want to know how to make extra bucks, search for: best adsense
    alternative Wrastain’s tools

  7. I see you don’t monetize your website, don’t waste your traffic,
    you can earn extra cash every month because you’ve got high quality content.
    If you want to know how to make extra money, search for:
    Boorfe’s tips best adsense alternative

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>