web.config内容:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation defaultLanguage="c#" debug="true" />
</system.web>
<appSettings>
<add key="ConnectionInfo" value="server=(local)database=NorthwindIntegrated Security=SSPI" />
</appSettings>
</configuration>
读取配置的方法:
void Page_Load(object sender, EventArgs e)
{
string connectionInfo = ConfigurationSettings.AppSettings["ConnectionInfo"]
using(SqlConnection connection = new SqlConnection(connectionInfo))
{
connection.Open()
// perform work with connection
}
}
给你我写的先配置数据连接
<appSettings>
<add key="con" value="server=.uid=sapwd=database=Blog"></add>
</appSettings>
con=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["con"])
其实就是key value结构
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)