Ask a Question related to Coldfusion Database Access, Design and Development.
-
jots_ozark #1
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
-
Dan Bracuk #2
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
-
jots_ozark #3
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
-
Major Doom #4
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
-
jots_ozark #5
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
-
Dan Bracuk #6
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
-
jots_ozark #7
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
-
Dan Bracuk #8
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
-
jots_ozark #9
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
-
mxstu #10
Re: Really need some help here on a CFC!
><cfreturn HotTopics> <--- query is named "topics" but code is returning
"HotTopics"jots_ozark,></cffunction>
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



Reply With Quote

