I agree.  I don't see any reason why a DSN needs to be in the Application,
or Server scope.
I normally just set this as a normal variable in the Application.cfm file.

ie.
        <cfset MyDSN = "DSN Name">
or
        <cfscript>
        // declare Application Level Constants
        App = structnew();
        StructInsert(App, "DSN", "CAA_EPMS2");
        </cfscript>

then call it like so:

<cfquery name="MyQuery" datasource="#MyDSN#">
or
<cfquery name="MyQuery" datasource="#App.DSN#">

Then, for an application wide setting, I simply need to change the value in
Application.cfm.

If you were on different servers, you could use the same DSN name, but
unfortunately you are not.  So you will need two distinct DSNs. (assuming
the development site, and the production site are running simultaneously, on
the same box).

HTH

Shawn Grover


-----Original Message-----
From: BILLY CRAVENS [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 14, 2001 9:42 AM
To: CF-Talk
Subject: Re: Can we have two datasources with the same name?


I used to make that same mistake.  However, if you use #application.dsn#,
that means that you have to lock every query - this really hurts
performance.  Use a non-shared scope (like request)

---
Billy Cravens

----- Original Message -----
From: "Larry Juncker" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Thursday, December 13, 2001 3:46 PM
Subject: RE: Can we have two datasources with the same name?


> If I understand what you are asking, why do you not just set your DSN as
> an Application variable?
>
> <cfset Application.DataSource = "dev"> or <cfset Application.DataSource =
> "test">
> You would use whichever one you wanted while testing and then
> just change this one spot in your Application.cfm file when you
> were ready to go live.
>
> Create the ODBC connections and just call the correct one in your code.
>
> In your templates then, your queries would be like:
>
> <CFQUERY NAME="qMyQuery" DATASOURCE="#Application.DataSource#">
>
> Larry Juncker
> Senior Cold Fusion Developer
> Heartland Communications Group, Inc.
> [EMAIL PROTECTED]
>
> -----Original Message-----
> From: bajaria aslam [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, December 13, 2001 3:36 PM
> To: CF-Talk
> Subject: Can we have two datasources with the same name?
>
>
> Hi.
>
> Suppose I have a datasource datasource1 pointing to
> Database1 on a SQL Server called test.
>
> Can I have another datasource called datasource1
> pointing to Database1 on SQL Server called dev?
>
> The datasource1 currently works fine on
> http://localhost/
>
> I have created a virtual site called
> http://localhost/Dev
>
> So, is there a way to have the same datasource name to
> point to different servers depending on if I am under
> http://localhost/ or http://localhost/dev?
>
> That way, I thought, I don't have to keep changing the
> cf code when the code moves to Test server from Dev.
>
> Please let me know if you need more details.
>
> Thanks
> AB
>
> __________________________________________________
> Do You Yahoo!?
> Check out Yahoo! Shopping and Yahoo! Auctions for all of
> your unique holiday gifts! Buy at http://shopping.yahoo.com
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to