Move conection settings to a config file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to move my connection settings out to a config file, rather than
having them hardcoded in my app. What is the best way of doing this? I
created a simple xml doc that looked something like this:

<Connection>
<DEV>........
</DEV>
<LIVE>.......
</LIVE
</Connection>

with my 2 diff connection strings in the relevant child nodes. And I have
put some code in to read this document, but my problem is how to trigger the
code to look at DEV instead of LIVE and vice versa? In past projects that I
have worked on (in none microsoft .Net worlds) we have passed parameters into
our config files, so for example I would pass in the word "LIVE" from the
shortcut that runs the application, then in my code I could just search for
the LIVE connection string. Any ideas please on how can I do this?
 
Why not have just one connection string, and just change the configuration
file when needed?
 
Why not? But, if security is a concern, make sure you encrypt the
connection string in the config file.
 
Back
Top