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
 
Back
Top