Get user and password from ConnectionStringSettings
问题 How can I get the user and password from such a connectionString in the app.config with a .NET function? Of course I could read that string and get the value after the ID= and Password=. <connectionStrings> <add name="MyConString" connectionString="Data Source=(local);Initial Catalog=MyDatabase;Persist Security Info=True;User ID=MyUsername Password=MyPassword;Connect providerName="System.Data.SqlClient"/> </connectionStrings> 回答1: use the ConnectionBuilderClass SqlConnectionStringBuilder