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

Multiple DSN in Application

Community Beginner ,
Sep 26, 2008 Sep 26, 2008
Can I set up multiple DSN in the application.cfc?
TOPICS
Database access
975
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
LEGEND ,
Sep 26, 2008 Sep 26, 2008
yes
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
Community Beginner ,
Sep 26, 2008 Sep 26, 2008
ok that is what I thought... so I can just do it like this:
<CFSET request.dsn = "enroll">
<CFSET request.projectdsn = "projects">
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
LEGEND ,
Sep 26, 2008 Sep 26, 2008
What happened when you tried it?
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
Community Beginner ,
Sep 26, 2008 Sep 26, 2008
Tells me that
Element PROJECTDSN is undefined in REQUEST.
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
LEGEND ,
Sep 26, 2008 Sep 26, 2008
cfdump the request scope. See what you get.

In what function are you setting these variables?
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
Community Beginner ,
Sep 30, 2008 Sep 30, 2008
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>
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
Community Beginner ,
Sep 30, 2008 Sep 30, 2008
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>


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
LEGEND ,
Sep 30, 2008 Sep 30, 2008
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/
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
New Here ,
Oct 02, 2008 Oct 02, 2008
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>
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
LEGEND ,
Oct 03, 2008 Oct 03, 2008
LATEST
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?
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