?
Solved

web.config asp.net

Posted on 2012-04-11
2
Medium Priority
?
371 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
yawkey13 earned 2000 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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

718 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