Oracle ODP & TNSNames Woes
I frequently move my webs from server to server as they enter test, dev, and production. Lately, keeping the Oracle TNSNames.ora files copisetic on each of these servers has became a NIGHTMARE because we have Oracle 9.2, 10g, 10.2, or whatever else is loaded up with the latest and greatest.
FOR TESTING, I recommend the following web.config solution:
Basically, if using ODP, you can replicate the TNSNames file inside of the web.config or connection string.
<add name="__INSTANCE__" connectionString="User Id=__USERNAME__; Password=__PASSWORD__; Data Source=(DESCRIPTION = (ADDRESS_LIST = (ADDRESS =(PROTOCOL = TCP)(HOST = __SERVER__)(PORT = __PORT__)) ) (CONNECT_DATA =(SERVER = DEDICATED) (SERVICE_NAME = __SERVICENAME__)))" />
In your actual data layer, just reference it as normal.
connString = ConfigurationManager.ConnectionStrings[“instance”].ConnectionString;
I’m sure, since that’s an OLD thread, everyone knows this… but I searched FOREVER to find it. I lose at Google. 😦