Solved

web.config asp.net

Posted on 2012-04-11
2
339 Views
Last Modified: 2012-04-11
Assume I have the following setting in asp.net/c# 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 asp.net/c# that we can easily just switch one time for all codes in getinformation.cs?

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

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

Accepted Solution

by:
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.
0
 

Author Comment

by:Webboy2008
ID: 37835983
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now