Move conection settings to a config file

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?
 
M

Marina

Why not have just one connection string, and just change the configuration
file when needed?
 
D

DCDev

Why not? But, if security is a concern, make sure you encrypt the
connection string in the config file.
 

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

Top