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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
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…

680 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