日期:2009-12-27 浏览次数:20500 次
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="zxz" connectionString="Data Source=192.168.1.81;Database=SMRS;User id=sa;PWD=reasee#1206"
providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="ConnectionString" value="Server=192.168.1.81;user id=sa;password=reasee#1206;database=SMRS"/>
</appSettings>
</configuration>
在方案里添加:1)添加引用System.Configuration
2)在.CS文件头上加上 using System.Configuration;
项目中调用:如果是connectionStrings,用ConfigurationManager.ConnectionStrings["add的name"].ConnectionString;
如果是appSettings,用ConfigurationManager.AppSettings["add的key"].ToString();
如:public static string SqlConnString = ConfigurationManager.AppSettings["ConnectionString"].ToString();