1
votes

I am from a PHP background and am very new to ColdFusion. I am using ColdFusion-10

I have created two files: a cfm file and a cfc file. When I am executing a query using cfquery in cfm file it is working. But when I am executing same in a cfc file, and calling the function in the cfm file, its throwing an error, saying the table name does not exist.

cfquery in both the files:

<cfquery name="test" dbtype="query">
    SELECT * FROM tbl_name
</cfquery>
1

1 Answers

6
votes

In your query you've specified dbtype="query". To CF that is telling it to query a query you have previously run on the page somewhere. In the CFC that query is probably not available because it was not passed in hence the error.

Maybe you mean to use this below and query your data source and not a query?

    <cfquery name="test" datasource="{put your CF datasource name here}">
    SELECT * FROM tbl_name
    </cfquery>