473,398 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

How do I dynamically switch SQL Connection to Test or Production environments?

I want my VB.Net windows application to be able to dynamically switch to
either a Production environment or a test environment. Currently my SQL
Connection string is hard coded in the data adapter code and other
program code. If I need to test or move the app to a different location
I don’t want to have to change the connection string throughout the app.
I would like to be able to “switch” the app to a different environment
by setting a switch or passing the connection string to the app instead
of hard coding it.

Any ideas on how best to do this are much appreciated.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
2 1523
You could persist it in the app.config

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<appSettings>

<add key="MyKey" value="MyValue" />

</appSettings>

</configuration>

MsgBox(System.Configuration.ConfigurationSettings. AppSettings.GetValues("MyK
ey")(0))
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Henry" <an*******@devdex.com> wrote in message
news:Oe**************@TK2MSFTNGP12.phx.gbl...
I want my VB.Net windows application to be able to dynamically switch to
either a Production environment or a test environment. Currently my SQL
Connection string is hard coded in the data adapter code and other
program code. If I need to test or move the app to a different location
I don't want to have to change the connection string throughout the app.
I would like to be able to "switch" the app to a different environment
by setting a switch or passing the connection string to the app instead
of hard coding it.

Any ideas on how best to do this are much appreciated.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #2
Tks much for the quick reply. I will follow-up on your app.config
suggestion.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
8
by: Nils Magnus Englund | last post by:
Hi, I have a production, test and development environment for my web application and a web service (The test web application connects to the test web service, and so on). Is it possible to...
5
by: Amelyan | last post by:
How can I get state of dynamically created controls (RadioButton, CheckBox, TextBox.Text) on post back when I click submit button? The only way I know is by traversing Response.Form enumberator;...
5
by: Saladin | last post by:
Hello I use a module to determine whether SQL connection is to my localhost or to my remote server. At moment, I enable either one or the other line of code to switch between, then build, (then...
2
by: MasterChief | last post by:
I have a OLEDB Connection String that is working very well for me. My question is that I read that you can store the Connection String in a seperate include file or somewhere else. I am just...
4
by: RedHair | last post by:
Development: Windows 2003 Production :Windows 2003 ASP.NET 2.0 + C# I want to disable the cache feature of all pages in dev but enable it in production environments. What's the solution? If...
2
by: steven | last post by:
hi as many web developers do, i sniff the URL of my app and toggle things like the db connection string, default email recipients, etc dynamically based on what i find (ie. dev.mysite.com,...
1
by: Dean Slindee | last post by:
VS2008, .NetFramework 3.5 SP1: I have built a LINQ data access layer project. When the LINQ data context was built over an existing SQL2005 database, the connection string for that database was...
2
by: Johnson | last post by:
I'm trying to fix a "sub optimal" situation with respect to connection string management. Your thoughtful responses will be appreciated. I just started with a new client who has a bunch of legacy...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.