一、config的两种调用方式。
-
自动生成:
<appSettings/>
< connectionStrings>
<add name="myConnStr" connectionString="Data Source=XIAOW\SQLEXPRESS;Initial Catalog=Codematic;Persist Security Info=True;User ID=pxd;Password=pxd"
providerName="System.Data.SqlClient" />
</connectionStrings>
SqlConnection myconn = new SqlConnection(ConfigurationManager.ConnectionStrings["myConnStr"].ToString()); -
手写
< appSettings>
<add key="myConnStr" value="Data Source=XIAOW\SQLEXPRESS;Initial Catalog=Codematic;User ID=pxd;Password=pxd"/>
</appSettings>
SqlConnection myconn = new SqlConnection(ConfigurationManager..AppSettings["myConnStr"];
提示: