S
shapper
Hello,
I have the following string:
String conn = " Provider=System.Data.SqlClient;
Metadata=c:\metadata|c:\Metadata\Sql;
Provider Connection String= 'Data Source=localhost; Initial
Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60'
";
This string contains pairs of Keys / Values. For example:
Provider=System.Data.SqlClient;
Becomes
Key = "Provider", Value = "System.Data.SqlClient".
";" separate each Key/Value pair.
If a Value contains '' I want to remove those. For example:
2) Provider Connection String= 'Data Source=localhost; Initial
Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60'
Becomes
Key = "Provider Connection String"
Value = "Data Source=localhost; Initial
Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60"
AND NOT:
Value = "'Data Source=localhost; Initial
Catalog=AdventureWorks;Integrated Security=True;Connection
Timeout=60'"
How can I parse such strings to a Dictionary<String, String>?
I am not sure if the string contains only 3 Key/Value pairs. I just
know that is follows this rule.
Thanks,
Miguel
I have the following string:
String conn = " Provider=System.Data.SqlClient;
Metadata=c:\metadata|c:\Metadata\Sql;
Provider Connection String= 'Data Source=localhost; Initial
Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60'
";
This string contains pairs of Keys / Values. For example:
Provider=System.Data.SqlClient;
Becomes
Key = "Provider", Value = "System.Data.SqlClient".
";" separate each Key/Value pair.
If a Value contains '' I want to remove those. For example:
2) Provider Connection String= 'Data Source=localhost; Initial
Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60'
Becomes
Key = "Provider Connection String"
Value = "Data Source=localhost; Initial
Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60"
AND NOT:
Value = "'Data Source=localhost; Initial
Catalog=AdventureWorks;Integrated Security=True;Connection
Timeout=60'"
How can I parse such strings to a Dictionary<String, String>?
I am not sure if the string contains only 3 Key/Value pairs. I just
know that is follows this rule.
Thanks,
Miguel