App.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name ="connString" connectionString ="server=.;pwd=sun;user=sa;database=SIM"/>
</connectionStrings>
</configuration>
类中调用:
private readonly string connString = ConfigurationManager.ConnectionStrings["connString"].ConnectionString;
SqlConnection conn = new SqlConnection(connString);
不过要在调用的类中导入
using System.Configuration;
在项目中要添加对System.Configuration的引用
[[it] 本帖最后由 klj92112 于 2008-10-28 14:06 编辑 [/it]]