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

  • Thread starter Thread starter Henry
  • Start date Start date
H

Henry

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.
 
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
 
Tks much for the quick reply. I will follow-up on your app.config
suggestion.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top