Posted on 2012-04-11
Last Modified: 2012-04-11
Assume I have the following setting in application - web.

in App_Code/GetInformation.cs

I need to use the connectionstring. In GetInformation.cs, we may frequently change from test to live. How can we code in that we can easily just switch one time for all codes in getinformation.cs?

    <add name="SqlDbConnectionTest" connectionString="Data Source=,1533;Initial Catalog=xxx;Persist Security Info=True;User ID=sa;Password=xxx" providerName="System.Data.SqlClient"/>

    <add name="SqlDbConnectionLive" connectionString="Data Source=,1533;Initial Catalog=xxx;Persist Security Info=True;User ID=sa;Password=xxx" providerName="System.Data.SqlClient"/>
Question by:Webboy2008

Accepted Solution

yawkey13 earned 500 total points
ID: 37835807
If you are not using both at the same time, change the name of both to "SqlDBConnection" omitting the "Test" and "Live".  You would then have one of them commented out depending on which one you wanted active.  That way you are only ever editing web.config.

Author Comment

ID: 37835983

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question