日期:2014-05-20  浏览次数:20427 次

如何获取Web.config的<connecttionString>的连接字符串
请问在vb.net里面怎样获取Web.config的 <connecttionString> 的连接字符串

------解决方案--------------------
ConfigurationSettings.AppSettings[webconfig-AppSettings下的关键字]

------解决方案--------------------
webConfig里这样写如:
<connectionStrings>
  <add name= "ConnStr " connectionString= "Data Source=.;Initial Catalog=JianCai;User   ID=sa;Password= " providerName= "System.Data.SqlClient "/>
</connectionStrings>
前台调用时:
protected SqlConnection con;
con= new SqlConnection(ConfigurationSettings.AppSettings[ "ConnStr "]);

------解决方案--------------------
ConfigurationSettings.AppSettings[]
------解决方案--------------------
ConfigurationSettings.AppSettings[ " "]
------解决方案--------------------
.net 2.0

ConfigurationManager.ConnectionStrings[ "ConnStr "]

========================================
传音石——网罗天下资源 http://www.massany.com
========================================
------解决方案--------------------
.net 2.0
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings[ "ConnectionString "].ToString());
------解决方案--------------------
楼上正解.
string connStr=ConfigurationManager.ConnectionStrings[ "ConnectionString "].ToString();
SqlConnection conn=new SqlConnection(connStr);
可以反复使用.
------解决方案--------------------
//读取config连接数据库字符串
protected static readonly string SQLConnectionString = ConfigurationManager.AppSettings[ "ConnectionString "];


100%成功
------解决方案--------------------
Configuration.ConfigurationSettings.AppSettings( "SqlConnStr ");
------解决方案--------------------
都说了,偶就不说了哈。。帮顶一下,快结了贴,给分