Mar 23, 2009

Read various elements from the connection string.

I saw a question in ASP.NET forums. There was a guy asking how to extract the Username and Password from a connection string, stored in the web.config.

I recalled doing something like this but was not able to recall which class I used.

After about a day another guy posted an answer on this question - the class was SqlConnectionStringBuilder. You can use this class to easilly manage SqlConnection string properties such as DataSource, Username, Password etc.

Here is my post on how to get a connection string from the web.config:
Read connection string from web.config

Here is some more info about SqlConnectionStringBuilder from MSDN:
SqlConnectionStringBuilder class

Combining both resources will help you manage your connection strings easilly.