Location and access method for global connection strings
-
Hello. I am developing some classes that access SQL and Oracle databases. These classes are to be used by different applications, (windows and web applications). Thus, I need to put the database connection strings on a global location so that all applications see them (this way if I need to do changes to a connection string all applications are affected). I found that machine.config might be a proper location to do that, under the section. - Is machine.config a good solution for global connection strings? - If so, how can I access the section in my code? Thanks.
-
Hello. I am developing some classes that access SQL and Oracle databases. These classes are to be used by different applications, (windows and web applications). Thus, I need to put the database connection strings on a global location so that all applications see them (this way if I need to do changes to a connection string all applications are affected). I found that machine.config might be a proper location to do that, under the section. - Is machine.config a good solution for global connection strings? - If so, how can I access the section in my code? Thanks.
Machine.config does seem like a good idea. You can use ConfigurationManager.OpenMachineConfig[^], which even has a ConnectionStrings[^] section to store and retrieve connection strings.
Regards Senthil [MVP - Visual C#] _____________________________ My Blog | My Articles | My Flickr | WinMacro