Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default CFQUERYPARAM Error

    Hello,

    I am using MX7 and am having problems with cfqueryparam. I am new to a
    project and the old code does not use them and everything I have built recently
    uses them.

    Now I intermittently receive application errors on only those queries that use
    cfqueryparam. All other queries work fine. The error is always something like:

    [Macromedia][SQLServer JDBC Driver][SQLServer]Could not find prepared
    statement with handle 5

    The number at the end changes, but the error is always the same. I haven't
    been able to get a clear indication of what is causing this. It occurs
    randomly throughout the day. But when it appears, all queries using
    cfqueryparam are broken for awhile. Then suddenly it will start working again,
    then fail again, etc.

    The code itself works fine, it seems like a server issue or a db connection
    issue or something. However, since other queries (not using query params)
    work, it almost seems specific to how CF deals with cfqueryparams.

    Has anyone experienced this? Any ideas on things to try?

    Thanks!
    Wendell

    wbartnick10 Guest

  2. Similar Questions and Discussions

    1. Attribute validation error for tag CFQUERYPARAM.
      I have a page that lets the user upload an image to change the logo of the website. It works fine on ColdFusion MX7 but on earlier versions I get...
    2. Problem using cfqueryparam
      CF throw me an error if I use <cfqueryparam cfsqltype="cf_sql_longvarchar"... on MS Access Memo field. My data in the Memo field is around 1000+...
    3. Error With CFQUERYPARAM
      Here is an error that only exists when cfqueryparam is used. The code below throws an error in the *second* query if the *first* query contains...
    4. cfqueryparam
      Hi, I am trying to take values passed through a form and do a search based on that, but I am getting an error Error Executing Database Query....
    5. cfqueryparam question
      Hi, all. I am not too sure where to put the cfqueryparam in my code below. Alos for for this code: where id =...
  3. #2

    Default Re: CFQUERYPARAM Error

    Hi all,

    Anyone run into this issue?
    wbartnick10 Guest

  4. #3

    Default Re: CFQUERYPARAM Error

    googling for that error shows it all over the map, XML, DTS, sql 2005, ODBC,
    etc.

    are you using the jdbc or odbc driver? what version of sql server? can you
    post the simplest query that is breaking?


    PaulH Guest

  5. #4

    Default Re: CFQUERYPARAM Error

    Thanks for the response. I googled as well and didn't find much helpful.

    We are using SQL Server 2000 and the JDBC driver that comes with CFMX 7
    installation. We have not installed any updates/hot fixes yet.

    Here is one example of a query that breaks. Remember, once one breaks, it
    seems that every query that uses cfqueryparam also breaks, though I don't know
    that 100%. All the queries that fail including this one are called from within
    a CFC.

    SELECT form_field_type_id
    FROM field_customized
    WHERE custom_field_id = <cfqueryparam cfsqltype="CF_SQL_INTEGER"
    value="#arguments.pCustomFieldID#">

    Hope this helps, let me know if you need anything else.

    wbartnick10 Guest

  6. #5

    Default Re: CFQUERYPARAM Error

    One more note.

    When the page errors, I can refresh any number of times and the page will still fail. Then if I change the query to not use the cfqueryparam, the page works.


    wbartnick10 Guest

  7. #6

    Default Re: CFQUERYPARAM Error

    This might be a better example, because I just see it erroring. When trying to
    debug this further, I seem to see problems in queries with if statements in the
    query. This may be a stupid question, but could this have something to do with
    the binding that occurs to help peformance? I don't know how it works, but
    perhaps ColdFusion stores one version of the query (say where the IF statement
    is true), then if the query runs when the IF statement is false, it errors. I
    honestly don't know.

    SELECT customer_learner_id
    FROM learners
    WHERE customer_learner_id IS NOT NULL
    AND customer_learner_id <> ''
    <cfif arguments.pStudentID IS NOT "">
    AND learnerid <> <cfqueryparam cfsqltype="CF_SQL_INTEGER"
    value="#arguments.pStudentID#">
    </cfif>

    wbartnick10 Guest

  8. #7

    Default Re: CFQUERYPARAM Error

    Try using:

    value="#Val(arguments.pStudentID)#">

    If arguments.pStudentID is not a number , it will change it to zero.

    OldCFer Guest

  9. #8

    Default Re: CFQUERYPARAM Error

    when you drop the cfqueryparam, does your data change as well? as larry points
    out it might simply be bad data. though if it was bad data, i think you would
    normally see an error thrown (are you swallowing the errors by any chance?).
    when this craps out, what shows up in the logs?

    frankly i'm not sure about using cfqueryparam within a cfif block, don't think
    i've ever used it that way. if it is the problem, you should be able to
    reproduce it easily. loop over the query making sure the logic uses the
    cfqueryparam, then toss in a few cases where it doesn't.


    PaulH Guest

  10. #9

    Default Re: CFQUERYPARAM Error

    I 'found' the solution. Basically, I just changed the jdbc driver and the
    error no longer occurs. I was using the jdbc driver that comes with the Cold
    Fusion MX 7 install. I changed the driver to the latest Microsoft's JDBC
    driver.

    Thanks for your help.

    wbartnick10 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139