惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
Martin Fowler
Martin Fowler
月光博客
月光博客
AI
AI
B
Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
CXSECURITY Database RSS Feed - CXSecurity.com
WordPress大学
WordPress大学
GbyAI
GbyAI
L
Lohrmann on Cybersecurity
O
OpenAI News
Schneier on Security
Schneier on Security
P
Palo Alto Networks Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Troy Hunt's Blog
V2EX - 技术
V2EX - 技术
W
WeLiveSecurity
L
LINUX DO - 最新话题
人人都是产品经理
人人都是产品经理
S
Security Affairs
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
A
Arctic Wolf
Recorded Future
Recorded Future
Microsoft Security Blog
Microsoft Security Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
G
GRAHAM CLULEY
N
Netflix TechBlog - Medium
TaoSecurity Blog
TaoSecurity Blog
C
Check Point Blog
Scott Helme
Scott Helme
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Apple Machine Learning Research
Apple Machine Learning Research
PCI Perspectives
PCI Perspectives
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Vercel News
Vercel News
The Hacker News
The Hacker News
Y
Y Combinator Blog
Latest news
Latest news
SecWiki News
SecWiki News
Hugging Face - Blog
Hugging Face - Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Google Online Security Blog
Google Online Security Blog
Webroot Blog
Webroot Blog
Google DeepMind News
Google DeepMind News
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Cisco Blogs
博客园_首页
H
Hackread – Cybersecurity News, Data Breaches, AI and More
宝玉的分享
宝玉的分享
L
LINUX DO - 热门话题

博客园 - 站在天空下的猪

SqlBulkCopy批量转移数据备注 根据文本框联动下拉框(jquery 插件) - 站在天空下的猪 - 博客园 关于用FOMR提交编码的问题 jquery 图片预览插件 - 站在天空下的猪 - 博客园 自己写的一个jquery模板引擎(json比较好用) Document 对象的常用方法 今天发现梅花雨日历控件蛮好用的哟,腾讯都在用 身份证对应县及县的行政区划代码 【SQLSERVER】存储过程基础 终于解决了一个AjaxPro无刷新的问题了,可以引用在短信方面滴asp.net 2.0 昨天很失败 一个简单的FileUpload处理逻辑 C# 判断是否为数字 DataBinder.Eval总结 asp.net 2.0中实现防盗链 如何把HTML语句直接保存到数据库 如何取得IP/用户名等信息 asp.net常用函数表 C#中计算两个时间的差
“ConnectionString 属性尚未初始化”的另类解决办法
站在天空下的猪 · 2007-05-16 · via 博客园 - 站在天空下的猪

“ConnectionString 属性尚未初始化”的另类解决办法

现在稍微熟悉Asp.net的朋友都习惯把数据库连接配置写到web.config中,这样的优点主要是能随时更改数据库配置(比如帐号密码)而不用再编译,web.config中的数据库中的配置如下:

1  <appSettings>
2    <add key="ConnString" value="user id=sa;password=sasasa;Data Source=(local);Initial Catalog=51aspx"/>
3  </appSettings>


.cs文件中利用

string strConn = ConfigurationManager.AppSettings["ConnString"];

来读取,值得注意的是:这个是Asp.net2.0的读取方式,1.1中是

string strConn=ConfigurationSettings.AppSettings["ConnString"]; 

很多朋友也许都遇到过“ConnectionString 属性尚未初始化”的提示,其中的根本原因是没有能读到key的值,解决方法是校正一下ConnString。

我今天也遇到了这个提示“ConnectionString 属性尚未初始化”,死活读不到web.config中的key值。

最后发现原因竟然是我当前建立的是http://localhost/test虚拟目录,默认读取的是站点http://localhost中的web.config的值,那里根本没有这个key,把test设置为站点(重新建立一个站点指向test或者把http://locanhost指向test)就OK了,希望这里能给大家提个醒,少走弯路哦!