Skip to main content
Participant
June 28, 2011
Answered

Error executing CFC. Parameter index out of range (2 > number of parameters, which is 1)

  • June 28, 2011
  • 1 reply
  • 2741 views

Hi,

My CFC component is defined as:

<cffunction name="updateNote" output="false" access="remote"  returntype="void" >

     <cfargument name="notedetails" required="true" type="string" >

     <cfargument name="notename" required="true" type="string" />

   

     <cfquery name="qupdateNote" datasource="notes_db">

           UPDATE

               notes

           SET

               notes.notedetails=<CFQUERYPARAM CFSQLTYPE="CF_SQL_VARCHAR" VALUE="#ARGUMENTS.notedetails#">,

           WHERE

               notename="<CFQUERYPARAM CFSQLTYPE="CF_SQL_VARCHAR" VALUE="#ARGUMENTS.notename#">"

    </cfquery>

</cffunction>

In Flash builder when I test the operation I get this error:

"There was an error while invoking the operation. Check  your server settings and try invoking the operation again.

Reason:  Server error Unable to invoke CFC - Error Executing Database Query. Parameter  index out of range (2 > number of parameters, which is 1)."

Im really quessing that this is something small but right now its causing me to pull my hair out of my head!! Argg. Tried a bunch of things but I know thik im stuck.

Help would be very very appreciated.

Thanks

    This topic has been closed for replies.
    Correct answer Dan_Bracuk

    The sql error is a comma.

    1 reply

    Inspiring
    June 28, 2011

    Your SQL is invalid: it has a syntax error in it.

    Take a (closer ~) look at it.

    It's always best to troubleshoot this stuff with a CF template and a normal web browser because you'll get a better error message and, in the case of SQL errors, it'll show the SQL it's trying to run, and it's easier to spot syntax errors that way.  Plus one can copy and paste the SQL from the debug into an SQL client app and run it, and often it'll highlight exactly where the error is.

    --

    Adam

    Participant
    June 29, 2011

    thanks a ton Adam. cant really find my sql error - i removed the "'s but it still wont work.

    can u give me a quick tip on how to use a cf template to create a webpage out of the component.

    much appreciated.

    Inspiring
    June 29, 2011

    Create test.cfm along these lines:

    <cfset myObj = createObject("component", "dotted.path.to.cfc.file")>

    <cfset myResult = myObj.myMethod(arg=value1, etc)>

    <cfdump var="#myResult#">


    Or, really, you could just browse to this:

    http://your.domain/path/to/your.cfc?method=yourMethod&arg1=value1 [etc]

    Although I dunno which of those two approachs will give you a better error message (indeed, it might be the same).

    Try both.

    --

    Adam