Not too long ago, I was working on a standard app that we were going to deploy at a few customer sites. One of the requirements of the project though is that I couldn't touch the registry. Security settings were such that I couldn't write to it so had to use another means (it doesn't seem so long ago that there wasn't even a registry).
Anyway, .NET gives you a great little mechanism for storing configuration information like connection strings, configuration files. There are a hundred zillion reasons not to hard code connection strings or anything else in your program, but that's another issue. So, if you are using ASP.NET you'll have a web.config file already, if not, add a Configuration file Project, Add New Iterm, Configuration File. Now add something like this to it:
| <appSettings> <add key="ConnectString" value="UID=xxx; PWD=xxxxx; Data Source=xxx;Initial Catalog=xxx"/> <add key="DefaultDB" value = "SomeDataBase"/> <add key="Cipher" value = "SomeCipher"/> appSettings> |
| 'To get the ConnectionString Key Dim cn As New SqlConnection(ConfigurationSettings.AppSettings("ConnectString")) 'To reference the Cipher key ConfigurationSettings.AppSettings("Cipher") 'To reference the DefaultDB key _DefaultDB = ConfigurationSettings.AppSettings("DefaultDB") |