VS2005 自动生成的web.config中连接字符串的程序取值问题...
2007-03-21 23:23
447 查看
问:
<appSettings>
<add key="ConnectionString" value="uid=sa;password=123456;database=gbdb;server=(local)"/>
</appSettings>
以上可以通过 ConfigurationSettings.AppSettings("ConnectionString") 取得,那么看下面的如何来取.
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings/>
<connectionStrings>
<add name="pubsConnectionString" connectionString="Data Source=.;Initial Catalog=pubs;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="PersonalConnectionString" connectionString="Data Source=.;Initial Catalog=Personal;Persist Security Info=True;User ID=sa;Password="
providerName="System.Data.SqlClient" />
</connectionStrings>
如上节点的web.config文件 如何取出pubsConnectionString 的串值?
答:System.Configuration.ConfigurationManager.ConnectionStrings["pubsConnectionString "].ToString();
<appSettings>
<add key="ConnectionString" value="uid=sa;password=123456;database=gbdb;server=(local)"/>
</appSettings>
以上可以通过 ConfigurationSettings.AppSettings("ConnectionString") 取得,那么看下面的如何来取.
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings/>
<connectionStrings>
<add name="pubsConnectionString" connectionString="Data Source=.;Initial Catalog=pubs;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="PersonalConnectionString" connectionString="Data Source=.;Initial Catalog=Personal;Persist Security Info=True;User ID=sa;Password="
providerName="System.Data.SqlClient" />
</connectionStrings>
如上节点的web.config文件 如何取出pubsConnectionString 的串值?
答:System.Configuration.ConfigurationManager.ConnectionStrings["pubsConnectionString "].ToString();
相关文章推荐
- 自动在Web.config中生成连接字符串
- 在ASP.NET项目中的web.config文件里配置数据库连接并在程序代码中获取连接字符串
- 在运行程序时报错:"如果在 Code First 模式下使用,则使用 T4 模板为 Database First 和 Model First 开发生成的代码可能无法 正常运行。若要继续使用 Database First 或 Model First,请确保在执行应用程序的 config 文件中指 定 Entity Framework 连接字符串。若要将这些从 Database First 或 Mod
- vs2005中在web.config里提取数据库连接字符串的笔记
- 在ASP.NET项目中的web.config文件里配置数据库连接并在程序代码中获取连接字符串
- 从Web.Config中读取数据库连接字符串的问题
- web程序通过dbcp连接池处理自动重新连接数据库问题(通过连接池dbcp处理方案)
- .Net Webconfig连接字符串中数据库实例名带'\'的问题
- ASP.NET项目中的web.config文件里配置数据库连接并在程序代码中获取连接字符串
- vs 2005 web.config不能自动生成的问题
- Web.config中关于数据库连接字符串配置问题
- Petapoco 连接oracle11g 自动生成poco时遇到的问题
- web.config中配置数据库连接字符串
- 怎样从web.config中读取连接字符串的设置
- ASP.NET数据库连接字符串写在config.web配置文件中(1)
- webconfig 配置连接数据库字符串
- 取web.config 连接字符串
- 在web.config里配制连接Access数据库字符串
- asp.net 2.0 中引用Web.config内的连接字符串的方法
- (译)利用ASP.NET加密和解密Web.config中连接字符串