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