0
Multiple DSN in Application
Community Beginner
,
/t5/coldfusion-discussions/multiple-dsn-in-application/td-p/848640
Sep 26, 2008
Sep 26, 2008
Copy link to clipboard
Copied
Can I set up multiple DSN in the application.cfc?
TOPICS
Database access
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/multiple-dsn-in-application/m-p/848641#M78261
Sep 26, 2008
Sep 26, 2008
Copy link to clipboard
Copied
yes
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
TheScarecrow
AUTHOR
Community Beginner
,
/t5/coldfusion-discussions/multiple-dsn-in-application/m-p/848642#M78262
Sep 26, 2008
Sep 26, 2008
Copy link to clipboard
Copied
ok that is what I thought... so I can just do it like this:
<CFSET request.dsn = "enroll">
<CFSET request.projectdsn = "projects">
<CFSET request.dsn = "enroll">
<CFSET request.projectdsn = "projects">
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/multiple-dsn-in-application/m-p/848643#M78263
Sep 26, 2008
Sep 26, 2008
Copy link to clipboard
Copied
What happened when you tried it?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
TheScarecrow
AUTHOR
Community Beginner
,
/t5/coldfusion-discussions/multiple-dsn-in-application/m-p/848644#M78264
Sep 26, 2008
Sep 26, 2008
Copy link to clipboard
Copied
Tells me that
Element PROJECTDSN is undefined in REQUEST.
Element PROJECTDSN is undefined in REQUEST.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/multiple-dsn-in-application/m-p/848645#M78265
Sep 26, 2008
Sep 26, 2008
Copy link to clipboard
Copied
cfdump the request scope. See what you get.
In what function are you setting these variables?
In what function are you setting these variables?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
TheScarecrow
AUTHOR
Community Beginner
,
/t5/coldfusion-discussions/multiple-dsn-in-application/m-p/848646#M78266
Sep 30, 2008
Sep 30, 2008
Copy link to clipboard
Copied
I am setting all of these in the Application.cfm
quote:
<cfcomponent output="false">
<cffunction name="onRequestStart" returntype="boolean" output="yes">
<!--- Any variables set here can be used by all our pages --->
<!--- <CFSET request.dataSource = "enroll">--->
<CFSET request.dsn = "test1`">
<CFSET request.dsn2 = "test2">
<CFSET request.companyName = "My Test">
<CFSET ErrorEmail = "cpersone@purdue.edu">
<cfreturn true>
</cffunction>
<!--- Name our application, and enable Application variables --->
<cfset THIS.name = "MyTest">
<cfset THIS.sessionmanagement ="yes">
<!--- Display Custom Message for "Request" Errors --->
<CFERROR TYPE="Request" TEMPLATE="ErrorRequest.cfm" MAILTO="cpersone@purdue.edu">
<!--- Display Custom Message for "Exception" Errors --->
<CFERROR TYPE="Exception" EXCEPTION="Any" TEMPLATE="ErrorException.cfm" MAILTO="cpersone@purdue.edu">
<!--- Display Custom Message for "Validation" Errors --->
<CFERROR TYPE="Validation" TEMPLATE="ErrorValidation.cfm">
<cffunction name="onMissingTemplate" returntype="boolean" output="no">
<cfargument name="targetpage" type="string" required="yes">
<!---log it --->
<cflog file="#THIS.name#" text="Missing Templage: #arguments.targetpage#">
<cflocation url="CF Testing/404.cfm?missingtemplate=#urlEncodedFormat(agruments.targetpage)#" addtoken="no">
</cffunction>
</cfcomponent>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
TheScarecrow
AUTHOR
Community Beginner
,
/t5/coldfusion-discussions/multiple-dsn-in-application/m-p/848648#M78268
Sep 30, 2008
Sep 30, 2008
Copy link to clipboard
Copied
Yes i meant cfc. ok I have made the correction for
projectdsn. At this point I am more concerend about why I cant get
projectdsn to be recognized throughout the site pages.
quote:
<cfcomponent output="false">
<cffunction name="onRequestStart" returntype="boolean" output="yes">
<!--- Any variables set here can be used by all our pages --->
<!--- <CFSET request.dataSource = "Test">--->
<CFSET request.dsn = "test1`">
<CFSET request.projectdsn= "test2">
<CFSET request.companyName = "My Test">
<CFSET ErrorEmail = "cpersone@purdue.edu">
<cfreturn true>
</cffunction>
<!--- Name our application, and enable Application variables --->
<cfset THIS.name = "MyTest">
<cfset THIS.sessionmanagement ="yes">
<!--- Display Custom Message for "Request" Errors --->
<CFERROR TYPE="Request" TEMPLATE="ErrorRequest.cfm" MAILTO="cpersone@purdue.edu">
<!--- Display Custom Message for "Exception" Errors --->
<CFERROR TYPE="Exception" EXCEPTION="Any" TEMPLATE="ErrorException.cfm" MAILTO="cpersone@purdue.edu">
<!--- Display Custom Message for "Validation" Errors --->
<CFERROR TYPE="Validation" TEMPLATE="ErrorValidation.cfm">
<cffunction name="onMissingTemplate" returntype="boolean" output="no">
<cfargument name="targetpage" type="string" required="yes">
<!---log it --->
<cflog file="#THIS.name#" text="Missing Templage: #arguments.targetpage#">
<cflocation url="CF Testing/404.cfm?missingtemplate=#urlEncodedFormat(agruments.targetpage)#" addtoken="no">
</cffunction>
</cfcomponent>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/multiple-dsn-in-application/m-p/848647#M78267
Sep 30, 2008
Sep 30, 2008
Copy link to clipboard
Copied
a) surely you meant Application.cfc, right?
b) i can;t see you setting request.projectdsn anywhere there...
c) the constructor part (setting THIS scope and cferror tags) should
really come before any cffunctions
d) if you ErrorEmail does not change from page to page, maybe consider
making it an application var...
e) i would probably add onApplicationStart, onSessionStart,
onRequestEnd, onSessionEnd and onApplicationEnd methods in there as
well, even if just with in bare minimum code.
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
b) i can;t see you setting request.projectdsn anywhere there...
c) the constructor part (setting THIS scope and cferror tags) should
really come before any cffunctions
d) if you ErrorEmail does not change from page to page, maybe consider
making it an application var...
e) i would probably add onApplicationStart, onSessionStart,
onRequestEnd, onSessionEnd and onApplicationEnd methods in there as
well, even if just with in bare minimum code.
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
/t5/coldfusion-discussions/multiple-dsn-in-application/m-p/848649#M78269
Oct 02, 2008
Oct 02, 2008
Copy link to clipboard
Copied
Hi
Please try the following line of code
<cfcomponent>
<cfparam name="application.error" default="0">
<cfset This.name = "testDSN">
<cfset This.Sessionmanagement="True">
<cfset This.loginstorage="session">
<cfset This.clientmanagement="True">
<cfset This.sessionTimeout=#CreateTimeSpan(0, 1, 0, 0)#>
<cffunction name="OnRequestStart">
<cfargument name = "request" required="true"/>
<cfset application.REQUEST.dsn="test_dsn1">
<cfset application.REQUEST.Reportdsn="test_dsn2">
<cfset application.REQUEST.Commondsn="test_dsn3">
</cffunction>
</cfcomponent>
Please try the following line of code
<cfcomponent>
<cfparam name="application.error" default="0">
<cfset This.name = "testDSN">
<cfset This.Sessionmanagement="True">
<cfset This.loginstorage="session">
<cfset This.clientmanagement="True">
<cfset This.sessionTimeout=#CreateTimeSpan(0, 1, 0, 0)#>
<cffunction name="OnRequestStart">
<cfargument name = "request" required="true"/>
<cfset application.REQUEST.dsn="test_dsn1">
<cfset application.REQUEST.Reportdsn="test_dsn2">
<cfset application.REQUEST.Commondsn="test_dsn3">
</cffunction>
</cfcomponent>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
LATEST
/t5/coldfusion-discussions/multiple-dsn-in-application/m-p/848650#M78270
Oct 03, 2008
Oct 03, 2008
Copy link to clipboard
Copied
quote:
Originally posted by: V.K.R
Hi
Please try the following line of code
<cfcomponent>
<cfparam name="application.error" default="0">
<cfset This.name = "testDSN">
<cfset This.Sessionmanagement="True">
<cfset This.loginstorage="session">
<cfset This.clientmanagement="True">
<cfset This.sessionTimeout=#CreateTimeSpan(0, 1, 0, 0)#>
<cffunction name="OnRequestStart">
<cfargument name = "request" required="true"/>
<cfset application.REQUEST.dsn="test_dsn1">
<cfset application.REQUEST.Reportdsn="test_dsn2">
<cfset application.REQUEST.Commondsn="test_dsn3">
</cffunction>
</cfcomponent>
Two questions.
1. Why would you set these variables on every page request instead of doing it once when you start the application?
2. Why would you double scope them, ie application.request.something instead of single scoping them, ie application.something?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

