Hi,
here is the way I'm doing it.
Set a machine identity in the machine.config that says if it is a
development, stage or production server (e.g. d, s or p. It might be good to
add an "l" for local also).
for the Development-server
<add key="ApplEnv" value="d" />
Then you can put the connection strings for all environments into the
web.config
<add key="ConnectionString-l" value="server=(local);......."/>
<add key="ConnectionString-d" value="server=DEV-Server;......"/>
<add key="ConnectionString-s" value="server=STG_Server;....."/>
<add key="ConnectionString-p" value="server=PRD-Server;....."/>
In your code put something like:
private static string DbConnectionString
{
get
{
string strApplEnv = ConfigurationSettings.AppSettings["ApplEnv"];
string paramSuffix = strApplEnv.ToLower().Substring(0,1);
return ConfigurationSettings.AppSettings["ConnectionString-" +
paramSuffix] ;
}
This way you can use the web.config for all environments.
Regards,
Uli
--
Wer nicht fragt, stirbt dumm.
If you don''t ask, you''ll die as a dumba**.
"Joel H" wrote:
We have several settings in web.config that are different on the developer
side than the production side. Our website sourcecode is under sourcesafe
control, so before we code, we check out the web.config and change our
connection strings to point to development databases, and change
"debug=true". Before we deploy, we change everything back. We can't
dynamically select the proper connection string in code because we are using
the tableadapter and dataset designer, which uses settings from web.config,
besides, there are other settings in the web.config that need to be different
while developing/debugging. Any suggestions for managing this better?
Joel