Skip to main content
Participating Frequently
March 8, 2010
Question

Datasource names for all the database tags within CFTRANSACTION must be the same

  • March 8, 2010
  • 1 reply
  • 778 views

I have a page which contains several queries in it.  All but one lie within a CFTransaction.  The one that lies outside of the CFTransaction has a different datasource than the others.  I don't understand why this error is being thrown.  Can someone shed some light on this?

This topic has been closed for replies.

1 reply

Inspiring
March 8, 2010

Can you post your code? (or a simplified version thereof).

What version of CF?

--

Adam

Participating Frequently
March 8, 2010

It's a lot of code, so I'll post an abbreviated version.  I believe this is CF 6.1.

<CFQUERY DATASOURCE="#strMainDSN#" name="qryEmails">
    SELECT user_id, user_firstname, user_lastname, user_email
    FROM users
    WHERE user_id in (#attributes.numReviewers#)
</CFQUERY>

<cffunction name="SendEmail" access="private" returnType="boolean">
    <cfargument name="userID" required="yes" type="numeric">
    <cfargument name="message" required="yes" type="string">

     ...
   
    <cfreturn true>
</cffunction>

...

<CFTRANSACTION ACTION="BEGIN">
<CFTRY>
    <CFQUERY DATASOURCE="#cookie.strProjectCode#">
        ...
    </CFQUERY>
   
    <CFQUERY DATASOURCE="#cookie.strProjectCode#" NAME="qryOriginalReviewers">
        ...
    </CFQUERY>


    <cfset newReviewers = attributes.numReviewers>
    <cfset newReviewManager = attributes.numReviewManager>
    <cfset arrOldReviewers = ListToArray(qryOriginalReviewers.resp_rev, ',')>
    <Cfset arrNewReviewers = ListToArray(newReviewers, ',')>

    <cfset removedReviewer = true>
    <cfloop index="oldID" from="1" to="#ArrayLen(arrOldReviewers)#">
        <cfloop index="newID" from="1" to="#ArrayLen(arrNewReviewers)#">
            <cfif arrOldReviewers[oldID] EQ arrNewReviewers[newID]>
                <cfset removedReviewer = false>               
            </cfif>
        </cfloop>
       
        <cfif removedReviewer EQ true>
            <cfset emailMessage = "<P><B><cfoutput>#Request.lblMsgHeadingRemovedReviewer##attributes.numLOID#</cfoutput></B></P><P><cfoutput>#Request.lblMsgRemovedReviewer#</cfoutput></P>">
            <cfoutput>#SendEmail(arrOldReviewers[oldID], emailMessage)#</cfoutput>
        </cfif>
    </cfloop>   
    <cfabort>
   
    <CFQUERY DATASOURCE="#cookie.strProjectCode#">
       ...
    </CFQUERY>
   
    <CFCATCH TYPE="DATABASE">
        <CFSCRIPT>
            strDetail="#CFCATCH.Message#<BR>#CFCATCH.Detail#";
        </CFSCRIPT>
    </CFCATCH>
</CFTRY>
</CFTRANSACTION>

Hopefully that's enough to give you an idea of what I'm doing.  I'm attempting to modify someone elses code, with only a minor understanding of CF.

Inspiring
March 8, 2010

Are you sure it's that query?  What happens if you take it out (perhaps hard-code a replacement query created with queryNew() if you need the data to be present)?

Is there a chance there's a function being called in the <cftransaction> block that has a query within it using a different DSN?

I don't have a CFMX61 install to fiddle around with to try to replicate this.  I can certainly mix DSNs within one template on CF8 & CF9.

--

Adam