There is a particular library I am using where I need to separately pass the database connection values separately: Username, Password, Host, and Database.
I took this project and someone else, and I noticed that the programmer, in addition to the connectionString used for the default configuration of the database, separately set these same data through <appSettings>
using <add key="Key" value="Value">
to implement specifically for that library cited above.
I do not think this is a good idea, since I would theoretically be repeating the same configuration I already have, but the difference is that it is written in connectionString
.
I was wondering if there is any way to transform a connectionString
into a key / value structure.
For example, I would like this string
below to become an object or dictionary.
"Data Source=.\SQLEXPRESS;Initial Catalog=Target_Database;User Id=User; Password=MyPassword"
How can I do this?