Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Multiples DSNs' application.cfc

Explorer ,
Aug 30, 2013 Aug 30, 2013

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

</cfquery>

Thanks

510
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Aug 30, 2013 Aug 30, 2013
LATEST

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#">

...

HTH,

-Carl V.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources