First, you must add the appSettings tag
<connectionStrings> <appSettings> <add name="SqlConnectionString" connectionString="Data Source=xxx.xx.xx.xx;Initial Catalog=xxxxx;User Id=xx;Password=xxx;" providerName="System.Data.SqlClient" /> </appSettings> </connectionStrings>
Secondly, add a link to System.Configuration in your project and paste using System.Configuration into your source code.
Then you can use ConfigurationManager.AppSettings to access the configuration settings:
string result = ConfigurationSettings.AppSettings["SqlConnectionString"];
shenhengbin
source share