Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Getting Started / May 2008



Tip: Looking for answers? Try searching our database.

CFC Query Return not working

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kdennis4 - 27 May 2008 19:05 GMT
Hello All,

Here is my code within the CFC:

<cffunction name="getThisProjectNumber" access="remote" returntype="string"
output="false">
        <cfargument name="thisProjectName" default="string" required="yes">
        <cfset var selectedNumber = ""/>
       
        <cfquery name="getProjectNumber" datasource="#datasource#">
            SELECT     creativeConfirmationNo.projectNumber,
                      creativeProjects.projectNameID, creativeProjects.projectName
            FROM       creativeConfirmationNo INNER JOIN
                       creativeProjects ON
creativeConfirmationNo.projectNameID =
                       creativeProjects.projectNameID
            WHERE     (creativeProjects.projectName = '#arguments.thisProjectName#')
        </cfquery>
       
            <cfset selectedNumber =
getProjectNumber.creativeConfirmationNo.projectNumber>
       
        <cfreturn selectedNumber>
    </cffunction>

I get this error with the above query:

CREATIVECONFIRMATIONNO.PROJECTNUMBER is undefined in GETPROJECTNUMBER.

So then I tried using the "as" projectNumber within the query so my <cfset
selectedNumber = getProjectNumber.projectNumber >

Neither one is working???  Any suggestions/solutions would be greatly
appreciated!

Cheers!
Dan Bracuk - 27 May 2008 19:16 GMT
give that column an alias.  also specify a row number.
Adam Cameron - 27 May 2008 19:38 GMT
> give that column an alias.  also specify a row number.

Added to that, when faced with errors that suggest the contents of a
variable are not what you expect them to be, a good place to start is to
<cfdump> the variable to see what it *does* contain.  I reckon had you done
that, you'd spot where you're going wrong...

Signature

Adam

kdennis4 - 27 May 2008 20:00 GMT
Here is what I have so far within my CFC now:

<cfquery name="getProjectNumber" datasource="#datasource#">
            SELECT     creativeConfirmationNo.projectNumber as ProjectNumber
            FROM       creativeConfirmationNo INNER JOIN
                       creativeProjects ON
creativeConfirmationNo.projectNameID =
                       creativeProjects.projectNameID
            WHERE     (creativeProjects.projectName = '#arguments.thisProjectName#')
        </cfquery>
       
            <cfset selectedNumber = getProjectNumber.ProjectNumber[1]>
       
        <cfreturn selectedNumber>

I have run my query in SQL server and I'm getting the one result, however it
is still not returning the data.  I've even placed a <cfset selectedNumber =
"here">... and that shows up????  Any other suggestions would be greatly
appreciated.

Cheers
Dan Bracuk - 27 May 2008 20:17 GMT
So when you run the query outside coldfusion you get one row but inside
coldfusion does not give you any rows?

Step Number 1 - make sure you are using the same database.

Step Number 2 - make sure you have de-bugging turned on in coldfusion.  Copy
and paste the sql from your debugging info into Query Analyzer, or whatever you
are using, to make sure it's the same query.
kdennis4 - 27 May 2008 20:23 GMT
I am posting this one to the CF Group... However, I'm using Flex 3.  So I took
another try at this one like this:

<cfloop query="getProjectNumber">
            <cfset selectedNumber = creativeConfirmationNo.projectNumber[1]>
        </cfloop>
        <cfreturn selectedNumber>

Still not returning anything to my Flex App.... Not sure if anyone else is
working with Flex in this group, but maybe there is another way that I can test
it.  Sure do appreciate all the help!

Cheers
kdennis4 - 27 May 2008 20:38 GMT
Hello All,

Thanks for all the suggestions.... it was in my Flex app.  At any rate this will help me with future queries.  I really do appreciate all the feedback!

Cheers
Dan Bracuk - 28 May 2008 00:48 GMT
[q][i]Originally posted by: [b][b]kdennis4[/b][/b][/i]
I am posting this one to the CF Group... However, I'm using Flex 3.  So I took
another try at this one like this:

<cfloop query="getProjectNumber">
            <cfset selectedNumber = creativeConfirmationNo.projectNumber[1]>
        </cfloop>
        <cfreturn selectedNumber>

Still not returning anything to my Flex App.... Not sure if anyone else is
working with Flex in this group, but maybe there is another way that I can test
it.  Sure do appreciate all the help!

Cheers[/q]
If you want to test to make sure your cfc is working correctly, invoke it from
a Cold Fusion template.  

To test getting data from a cfc to flex, use as simple a cfc as you can write.


Once you have done both separately, combine them.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.