.net - Is there any connection string parser in C#? -


i have connection string , want able peek out example "data source". there parser, or have search string?

yes, there's system.data.common.dbconnectionstringbuilder class.

the dbconnectionstringbuilder class provides base class typed connection string builders (sqlconnectionstringbuilder, oledbconnectionstringbuilder, , on) derive. connection string builders let developers programmatically create syntactically correct connection strings, , parse , rebuild existing connection strings.

the subclasses of interest are:

system.data.entityclient.entityconnectionstringbuilder system.data.odbc.odbcconnectionstringbuilder system.data.oledb.oledbconnectionstringbuilder system.data.oracleclient.oracleconnectionstringbuilder system.data.sqlclient.sqlconnectionstringbuilder 

for example, "peek out data source" sql-server connection string, can do:

var builder = new sqlconnectionstringbuilder(connectionstring); var datasource = builder.datasource; 

Comments

Popular posts from this blog

symfony - InvalidConfigurationException in SecurityExtension.php line 429: No authentication listener registered for firewall "secured_area" -

angular ui router - 10 digest iterations reached in angularjs when using $state.go -

javascript - Handling constructor related functions while testing with mocha and sinon -