Is there any function to solve the string to values?

  • Thread starter Thread starter ABC
  • Start date Start date
A

ABC

Is there any function to solve the string to values?

for example:

The string is "data source=DEVSRV;Initial Catalog=MyDATABASE;User
ID=sa;Password=;".

I expected the function can return the value of "data source" is DEVSRV,
"Initial Catalog" is MyDatabase, "User ID" is sa, "Password" is empty
string.
 
Well, if you know it is always a simple string you could just Spilt or
Regex it, but if you need something more generic:

DbConnectionStringBuilder builder = new
DbConnectionStringBuilder();
builder.ConnectionString = @"data source=DEVSRV;Initial
Catalog=MyDATABASE;User ID=sa;Password=;";
foreach (string key in builder.Keys) {
Console.WriteLine(key + " is " + builder[key]);
}

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top