Solved

web.config asp.net

Posted on 2012-04-11
2
334 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 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

14 Experts available now in Live!

Get 1:1 Help Now