By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,344 Members | 1,147 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,344 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.