How to find Datasource from Connection String?

Recently, I stumbled upon request to show data source property from Connection String to the end user. While, we can always split and parse the values, I was wondering about easy options for this and found ‘OledbConnectionStringBuilder’ class (Similar class available for SQL too)

To find Connection String parameters, just use it one of its method as below

return new OledbConnectionStringBuilder(ConnectionString).DataSource;

Simple and effective way to get the value..

(Visited 6 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *

How to find Datasource from Connection String?

Recently, I stumbled upon request to show data source property from Connection String to the end user. While, we can always split and parse the values, I was wondering about easy options for this and found ‘OledbConnectionStringBuilder’ class (Similar class available for SQL too)

To find Connection String parameters, just use it one of its method as below

return new OledbConnectionStringBuilder(ConnectionString).DataSource;

Simple and effective way to get the value..

(Visited 1 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *