If you happen to use many databases or need to switch between development databases and production, there is a quick way to keep all of your database connections manageable. By moving all of your connection strings into a separate file, you can quickly comment and uncomment them and add as many as you like without cluttering up the web.config file.
Simply create a file named "connectionStrings.config" and place in the root directory of your web application. Then cut and paste all of your connection strings onto this file, to include the beginning and ending tags.
You should have a file that looks like this now: connectionStrings.config
<connectionStrings>
<add name="SiteSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|Database.mdf;"/>
<add name="Database1" connectionString="Data Source=Server1;Database=Important1; User ID=******; pwd=*****;" providerName="System.Data.SqlClient"/>
<add name="Database2" connectionString="Data Source=Server2;Database=Important2; User ID=******; pwd=*****;" providerName="System.Data.SqlClient"/>
<add name="Database3" connectionString="Data Source=Server3;Database=Important3; User ID=******; pwd=*****;" providerName="System.Data.SqlClient"/>
<add name="Database4" connectionString="Data Source=Server4;Database=Important4; User ID=******; pwd=*****;" providerName="System.Data.SqlClient"/>
<add name="Database5" connectionString="Data Source=Server5;IDatabase=Important5; User ID=******; pwd=*****;" providerName="System.Data.SqlClient"/>
connectionStrings>
Now, modify the Web.config
So, now that you have removed all the connection string information, simply add this back in the same spot on the web.config file:
<connectionStrings configSource="connectionStrings.config"/>
That's it. Now you've got a separate, easy to read file just to hold your connection strings. So go ahead...go nuts...add as many as you need! WooHoo!