Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2011
    Posts
    148
    Thanks
    18
    Thanked 0 Times in 0 Posts

    invoke application.dns

    Hi guys,

    i have build my application.cfc file and i am using the following to declare my dns under application start session :

    <cfset application.dns="MyDNS">


    now how can i call that #application.dns# as my data source in other cfm pages ?



    thanks
    Last edited by korssane; 10-22-2011 at 04:19 AM.

  • #2
    Regular Coder
    Join Date
    Feb 2009
    Location
    NJ, USA
    Posts
    476
    Thanks
    2
    Thanked 70 Times in 69 Posts
    Exactly as you have it. You can put it in a <cfquery> as such:
    Code:
    <cfquery name="myQuery" datasource="#application.dsn#">
       (query text)
    </cfquery>
    Be aware though that the onApplicationStart method only runs on the first request to an application. This means that if you have added that <cfset> after running some pages in your application, #application.dsn# will not be set until you do one of the following:
    a) Restart the ColdFusion service on your computer.
    b) Let the application time out (which you probably don't want to wait for!), or
    c) If you have ColdFusion 9, you can run the applicationStop() function in a .cfm page, and the next request to a page will cause onApplicationStart() to execute, and set your variable.

    -Greg

  • #3
    Regular Coder
    Join Date
    Jun 2011
    Posts
    148
    Thanks
    18
    Thanked 0 Times in 0 Posts
    thanks Gjslick,

    do you think this is something needs to be called on RequestStart..

    i am using only 2 dsn's in whole applications

    thanks

  • #4
    Regular Coder
    Join Date
    Feb 2009
    Location
    NJ, USA
    Posts
    476
    Thanks
    2
    Thanked 70 Times in 69 Posts
    Hey korrsane,

    No, this is something that belongs in onApplicationStart. The <cfset> for application.dsn should only have to execute once when the ColdFusion application starts, and not on every request to a .cfm page.

    -Greg

  • #5
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by korssane View Post
    thanks Gjslick,

    do you think this is something needs to be called on RequestStart..

    i am using only 2 dsn's in whole applications

    thanks

    I also think so.
    __________________
    Watch The Twilight Saga: Breaking Dawn Online Free


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •