Really need some help here on a CFC!

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

  1. #1

    Default Really need some help here on a CFC!

    I am using MS Access and I try and run a CFM page using the CFC page I created
    for Update, Delete and Add, and I keep getting this in the browser:

    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft
    Access Driver] Too few parameters. Expected 2.

    The error occurred in C:\CFusionMX7\wwwroot\congress\components\conner.c fc:
    line 21
    Called from C:\CFusionMX7\wwwroot\congress\admin\issues\topics _grid.cfm: line 6
    Called from C:\CFusionMX7\wwwroot\congress\components\conner.c fc: line 21
    Called from C:\CFusionMX7\wwwroot\congress\admin\issues\topics _grid.cfm: line 6

    19 :
    20 :
    21 : <cfquery name="topics" datasource="#ds#">
    22 :
    23 : SELECT TopicsId, TopicTitle

    SQL SELECT TopicsId, TopicTitle FROM HotTopics ORDER BY TopicId
    DATASOURCE conner
    VENDORERRORCODE -3010
    SQLSTATE 07002

    --------------------------------------------------------------------------------
    --------------------------------------------------------------------------------
    -------

    And here is a copy of my CFC:

    <!---
    Filename: hottopics.cfc
    Author: Bob Williams (jots_ozark@yahoo.com)
    Purpose: Component File for delete, edit and adding Hot Topics
    Created: 11/28/05
    --->

    <cfcomponent hint="Conner hot topic database access">

    <!--- Set the datsources --->
    <cfset ds="conner">


    <!--- Get hot topics list --->
    <cffunction name="list"
    returntype="query"
    hint="List all topics">


    <cfquery name="topics" datasource="#ds#">

    SELECT TopicsId, TopicTitle
    FROM HotTopics
    ORDER BY TopicId
    </cfquery>


    <cfreturn HotTopics>
    </cffunction>


    <!--- Get details for a topic --->
    <cffunction name="get"
    returntype="query"
    hint="Get topic details">
    <cfargument name="TopicsId"
    type="numeric"
    required="yes"
    hint="Topics ID">

    <cfquery datasource="#ds#"
    name="topics">
    SELECT TopicsId, TopicsTitle,
    TopicsIntroduction, TopicsBody,
    FROM HotTopics
    WHERE TopicsId=#ARGUMENTS.TopicsId#
    </cfquery>
    <cfreturn topics>

    </cffunction>


    <!--- Add a topic --->
    <cffunction name="add"
    returntype="boolean"
    hint="Add a topic">

    <!--- Method arguments --->
    <cfargument name="TopicsTitle"
    type="string"
    required="yes"
    hint="Topics Title">
    <cfargument name="TopicsIntroduction"
    type="string"
    required="yes"
    hint="Intro to Topic">
    <cfargument name="TopicsBody"
    type="numeric"
    required="yes"
    hint="Body of the topic">

    <!--- Insert topic --->
    <cfquery datasource="#ds#">
    INSERT INTO HotTopics(TopicsTitle,
    TopicsIntroduction,
    TopicsBody)

    VALUES('#Trim(ARGUMENTS.TopicsTitle)#',
    '#Trim(ARGUMENTS.TopicsIntroduction)#',
    #ARGUMENTS.TopicsBody#)

    </cfquery>
    <cfreturn true>

    </cffunction>


    <!--- Update a Topic --->
    <cffunction name="update"
    returntype="boolean"
    hint="Update a topic">
    <!--- Method arguments --->
    <cfargument name="TopicId"
    type="numeric"
    required="yes"
    hint="Topic ID">
    <cfargument name="TopicsTitle"
    type="string"
    required="yes"
    hint="Topics Title">
    <cfargument name="TopicsIntroduction"
    type="string"
    required="yes"
    hint="Intro to topic">
    <cfargument name="TopicsBody"
    type="numeric"
    required="yes"
    hint="Body of topic">

    <!--- Update Topics --->
    <cfquery datasource="#ds#">
    UPDATE HotTopics
    SET TopicsTitle='#Trim(ARGUMENTS.TopicsTitle)#',
    TopicsIntroduction='#Trim(ARGUMENTS.TopicsIntroduc tion)#',
    TopicsBody=#ARGUMENTS.TopicsBody#

    WHERE TopicsId=#ARGUMENTS.TopicsId#
    </cfquery>
    <cfreturn true>

    </cffunction>


    <!--- Delete a Topic --->
    <cffunction name="delete"
    returntype="boolean"
    hint="Delete a topic">
    <cfargument name="TopicsId"
    type="numeric"
    required="yes"
    hint="topic ID">

    <cfquery datasource="#ds#">
    DELETE FROM HotTopics
    WHERE TopicsId=#ARGUMENTS.TopicsId#
    </cfquery>
    <cfreturn true>

    </cffunction>

    </cfcomponent>

    --------------------------------------------------------------------------------
    --------------------------------------------------------------------------------
    ------

    Can anyone help me?
    I am at my wits end and I have to get this site fully up and running in 8
    days. I was only given 14 to begin with.
    I am fairly new at CF Programming.

    jots_ozark Guest

  2. #2

    Default Re: Really need some help here on a CFC!

    Is the name of your field topicsid or topicid? Your query has one in the
    select clause and one in the order by clause.

    Originally posted by: jots_ozark
    I am using MS Access and I try and run a CFM page using the CFC page I created
    for Update, Delete and Add, and I keep getting this in the browser:

    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft
    Access Driver] Too few parameters. Expected 2.

    The error occurred in C:\CFusionMX7\wwwroot\congress\components\conner.c fc:
    line 21
    Called from C:\CFusionMX7\wwwroot\congress\admin\issues\topics _grid.cfm: line 6
    Called from C:\CFusionMX7\wwwroot\congress\components\conner.c fc: line 21
    Called from C:\CFusionMX7\wwwroot\congress\admin\issues\topics _grid.cfm: line 6

    19 :
    20 :
    21 : <cfquery name="topics" datasource="#ds#">
    22 :
    23 : SELECT TopicsId, TopicTitle

    SQL SELECT TopicsId, TopicTitle FROM HotTopics ORDER BY TopicId
    DATASOURCE conner
    VENDORERRORCODE -3010
    SQLSTATE 07002

    --------------------------------------------------------------------------------
    --------------------------------------------------------------------------------
    -------

    And here is a copy of my CFC:

    <!---
    Filename: hottopics.cfc
    Author: Bob Williams (jots_ozark@yahoo.com)
    Purpose: Component File for delete, edit and adding Hot Topics
    Created: 11/28/05
    --->

    <cfcomponent hint="Conner hot topic database access">

    <!--- Set the datsources --->
    <cfset ds="conner">


    <!--- Get hot topics list --->
    <cffunction name="list"
    returntype="query"
    hint="List all topics">


    <cfquery name="topics" datasource="#ds#">

    SELECT TopicsId, TopicTitle
    FROM HotTopics
    ORDER BY TopicId
    </cfquery>


    <cfreturn HotTopics>
    </cffunction>


    <!--- Get details for a topic --->
    <cffunction name="get"
    returntype="query"
    hint="Get topic details">
    <cfargument name="TopicsId"
    type="numeric"
    required="yes"
    hint="Topics ID">

    <cfquery datasource="#ds#"
    name="topics">
    SELECT TopicsId, TopicsTitle,
    TopicsIntroduction, TopicsBody,
    FROM HotTopics
    WHERE TopicsId=#ARGUMENTS.TopicsId#
    </cfquery>
    <cfreturn topics>

    </cffunction>


    <!--- Add a topic --->
    <cffunction name="add"
    returntype="boolean"
    hint="Add a topic">

    <!--- Method arguments --->
    <cfargument name="TopicsTitle"
    type="string"
    required="yes"
    hint="Topics Title">
    <cfargument name="TopicsIntroduction"
    type="string"
    required="yes"
    hint="Intro to Topic">
    <cfargument name="TopicsBody"
    type="numeric"
    required="yes"
    hint="Body of the topic">

    <!--- Insert topic --->
    <cfquery datasource="#ds#">
    INSERT INTO HotTopics(TopicsTitle,
    TopicsIntroduction,
    TopicsBody)

    VALUES('#Trim(ARGUMENTS.TopicsTitle)#',
    '#Trim(ARGUMENTS.TopicsIntroduction)#',
    #ARGUMENTS.TopicsBody#)

    </cfquery>
    <cfreturn true>

    </cffunction>


    <!--- Update a Topic --->
    <cffunction name="update"
    returntype="boolean"
    hint="Update a topic">
    <!--- Method arguments --->
    <cfargument name="TopicId"
    type="numeric"
    required="yes"
    hint="Topic ID">
    <cfargument name="TopicsTitle"
    type="string"
    required="yes"
    hint="Topics Title">
    <cfargument name="TopicsIntroduction"
    type="string"
    required="yes"
    hint="Intro to topic">
    <cfargument name="TopicsBody"
    type="numeric"
    required="yes"
    hint="Body of topic">

    <!--- Update Topics --->
    <cfquery datasource="#ds#">
    UPDATE HotTopics
    SET TopicsTitle='#Trim(ARGUMENTS.TopicsTitle)#',
    TopicsIntroduction='#Trim(ARGUMENTS.TopicsIntroduc tion)#',
    TopicsBody=#ARGUMENTS.TopicsBody#

    WHERE TopicsId=#ARGUMENTS.TopicsId#
    </cfquery>
    <cfreturn true>

    </cffunction>


    <!--- Delete a Topic --->
    <cffunction name="delete"
    returntype="boolean"
    hint="Delete a topic">
    <cfargument name="TopicsId"
    type="numeric"
    required="yes"
    hint="topic ID">

    <cfquery datasource="#ds#">
    DELETE FROM HotTopics
    WHERE TopicsId=#ARGUMENTS.TopicsId#
    </cfquery>
    <cfreturn true>

    </cffunction>

    </cfcomponent>

    --------------------------------------------------------------------------------
    --------------------------------------------------------------------------------
    ------

    Can anyone help me?
    I am at my wits end and I have to get this site fully up and running in 8
    days. I was only given 14 to begin with.
    I am fairly new at CF Programming.



    Dan Bracuk Guest

  3. #3

    Default Re: Really need some help here on a CFC!

    It is TopicsId, and I noticed that after I posted this. I corrected it and still saying there is something wrong with that line 21.
    jots_ozark Guest

  4. #4

    Default Re: Really need some help here on a CFC!

    The problem is with the reference to the datasource. The correct statement for
    <cfquery> should be:

    <cfquery name="topics" datasource="conner">

    Assuming, based on the <cfset ds="conner">, is the name of the datasource.
    The datasource attribute takes the NAME of the DSN that you set up within
    ColdFusion Administrator, not a value, which is what you were trying to do.
    Try it out with the above suggested code, and be sure to adjsut the other
    CFQUERY tags within your code.

    I hope this helps.

    Major Doom Guest

  5. #5

    Default Re: Really need some help here on a CFC!

    I tried the above code and it still hangs up on the "<cfquery name= topics"
    The line that it keeps getting stuck on at the CFM page is:
    <cfinvoke component="congress.components.conner"
    method="topics"
    returnvariable="conner">
    Is there something wrong here as to why it hangs up?

    jots_ozark Guest

  6. #6

    Default Re: Really need some help here on a CFC!

    I took a quick look at your cfc and didn't see any functions named topics. But
    I could have missed it.

    Or maybe you meant
    method="list"

    Also, if your cfc is named hottopics, why does your cfinvoke tag say
    component="congress.components.conner" ?

    Originally posted by: jots_ozark
    I tried the above code and it still hangs up on the "<cfquery name= topics"
    The line that it keeps getting stuck on at the CFM page is:
    <cfinvoke component="congress.components.conner"
    method="topics"
    returnvariable="conner">
    Is there something wrong here as to why it hangs up?



    Dan Bracuk Guest

  7. #7

    Default Re: Really need some help here on a CFC!

    The name of the CFC is "conner", the cfinvoke is showing the .cfm page what
    files to go through to find conner.cfc

    I have to have something in the wrong place or I don't have something tied
    together right. But I don't understand why it is hanging up on the "name" that
    I gave the query.

    jots_ozark Guest

  8. #8

    Default Re: Really need some help here on a CFC!

    Are you sure the name of the query is your problem? Run in in a normal cfm page, not cfc, and see if it works.
    Dan Bracuk Guest

  9. #9

    Default Re: Really need some help here on a CFC!

    I have done that.

    Infact I named the "name" something that does not even relate to the files in
    any way, such as "jobobbucktooth" and it works fine. But when I use this CFC it
    hangs up on this line 21. I split the "datasource" and the "name" between two
    different lines to see which one was giving me the trouble and it keeps saying
    it's the "name". I am about to throw a brick at this computer. I have wasted a
    whole day on this.

    Should I just give up on the idea of using a CFC for now?

    jots_ozark Guest

  10. #10

    Default Re: Really need some help here on a CFC!

    ><cfreturn HotTopics> <--- query is named "topics" but code is returning
    "HotTopics"
    ></cffunction>
    jots_ozark,

    Keep in mind that the line numbers in the error messages aren't always exact.
    In addition to what has already been suggested, you might try creating a
    simplified version of your CFC, with just the "list" function. Assuming the
    sql query is valid, and your files are in the right location, the attached
    should work correctly. Once you get the "list" function working, try adding
    back the other functions one at a time, making sure to test each one.



    <!---- conner.cfc ---->
    <cfcomponent hint="Conner hot topic database access">
    <!--- Set the datsources --->
    <cfset ds="conner">
    <!--- Get hot topics list --->
    <cffunction name="list" returntype="query" hint="List all topics">
    <!--- "var" local function variables --->
    <cfset var topics = "">
    <cfquery name="topics" datasource="#ds#">
    SELECT TopicsId, TopicTitle
    FROM HotTopics
    ORDER BY TopicsId
    </cfquery>
    <cfreturn topics>
    </cffunction>
    </cfcomponent>

    <!--- testing CFM page --->
    <cfinvoke component="congress.components.conner" method="list"
    returnvariable="conner">
    <cfdump var="#conner#">

    mxstu 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