1 Reply Latest reply on Aug 30, 2013 9:15 AM by Carl Von Stetten

    Multiples DSNs' application.cfc

    kt03 Level 1

      Hi All,


      Is it possible to set the multiple datasources on a Application.cfc using this.datasouce attribute?


      CF 9, from application.cfc, you  can set

      <cfset this datasouce ="myDSN1" > and no need to specify the DSN in the query.  My question is if I have multiples Datasouces, how can i set them up in application.cfc?



      cfquery name="qDoctype">

      select * from type




        • 1. Re: Multiples DSNs' application.cfc
          Carl Von Stetten Adobe Community Professional & MVP

          You can't set up multiple datasources in Application.cfc to be used **implicitly** in your queries.  The "this.datasource" can only be set to one datasource name.  However, nothing is stopping you from storing a structure of datasource names in the application scope:


          <cfset application.myDSNs = StructNew()>

          <cfset application.myDSNs.DSN1 = "myDSN1">

          <cfset application.myDSNs.DSN2 = "myDSN2">



          Then in your query, you would do:


          <cfquery name="qDoctype" datasource="#application.myDSNs.DSN1#">





          -Carl V.

          1 person found this helpful