日期:2014-05-18 浏览次数:20644 次
<connectionStrings> <add name="GPD" connectionString="data source=172.16.161.*;User ID=sa;pwd=test;Initial Catalog=GPD" /> </connectionStrings>
<configuration> <appSettings> <add key="conStr" value="Server=.;Database=ETer;uid=sa;pwd=sa"/> </appSettings> <connectionStrings/>
------解决方案--------------------
//添加引用 using System.Configuration; //获取配置文件连接字符串 String connStr = ConfigurationManager.ConnectionStrings["connectionString"].ToString();
------解决方案--------------------
//添加引用
using System.Configuration;
//获取配置文件连接字符串
String connStr = ConfigurationManager.ConnectionStrings["GPD"].ToString();
------解决方案--------------------
配置文件中:
</connectionStrings>
<connectionStrings>
<add name="GPD" value="data source=172.16.161.*;User ID=sa;pwd=test;Initial Catalog=GPD" />
</connectionStrings>
CS中
//添加引用
using System.Configuration;
//获取配置文件连接字符串
String connStr = ConfigurationManager.ConnectionStrings["GPD"].ToString();
------解决方案--------------------
string connstr=System.Configuration.ConfigurationSettings.AppSettings["GPD"];