Managing multiple data source connection string parameter in Web.config

G

Guest

Hello everyone,

I have a newbie question that I am sure you have probably encountered.

I am developing a ASP NET app that interfaces to a database ( SqlServer).

When I am developing I use my local version of MSSQL - so the connection string has something like:
connectionString="Data Source=myLocalMachine;Initial Catalog=my_db;Persist Security Info=True;User ID=...etc"

But when the app is released, I have to change "myLocalMachine" to the live or released database server "bigBusinessSqlServer392".

How can I manage my Web.config files so that I don't have to manually change each and every connection string on each release cycle?

If I was programming in C/C++, I could just have a string literal with a #define and/or compiler directive.

#ifdef _DEVELOPMENT

string dbserver = "myLocalMachine";

#else

string dbserver = "bigBusinessSqlServer392"

#endif

Is there an elegant / easy way to do this in ASP NET with web.config?

Thanks in advance.

bruce
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top