Posts Tagged ‘connection string’
I have been working on creating some .NET dlls at work which would commonly be utilized by our web applications. And, one of the requirements was getting the connection string information from web.config file. Simply making the call by using the ConfigurationManager class wouldn’t work since it was giving some kind of compile time error when you try to build the dll. So, I needed to find a workaround to retrieve the connection string from either connectionStrings or appSettings elements. Here is the solution that I have figured out so far.
Generic function that grabs the information based on your connection string name:
To understand the ConnectionStringSettingsCollection and NameValueCollection classes, followings links would be helpful: