Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.