.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

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -