首页上一页 1 下一页尾页 1 条记录 1/1页
C#项目开发全程实录 实例六中
发表在C#图书答疑
2008-11-19
是否精华
是
否
版块置顶:
是
否
C#项目开发全程实录 实例六中,我添加了一个app.config 如下:
<appSettings>
<add key="conn" value="Data Source=.\SQLEXPRESS;AttachDbFilename=E:\MrCy\MrCy\DataBase\db_MrCy.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True"/>
</appSettings>
用 ConfigurationSettings.AppSettings["conn"] 取出连接字串,但调试时提示:
警告“System.Configuration.ConfigurationSettings.AppSettings”已过时:“This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings”
-------------------------------------------------
我用 ConfigurationManager.AppSettings["conn"] 取字串,
提示:错误 当前上下文中不存在名称“ConfigurationManager”
---------------------------------
我用的是VS2005开发环境,在帮助文档里有ConfigurationManager,但在输入代码时确实没有 ConfigurationManager提示可选。
怎么从app.config取连接字串?
<appSettings>
<add key="conn" value="Data Source=.\SQLEXPRESS;AttachDbFilename=E:\MrCy\MrCy\DataBase\db_MrCy.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True"/>
</appSettings>
用 ConfigurationSettings.AppSettings["conn"] 取出连接字串,但调试时提示:
警告“System.Configuration.ConfigurationSettings.AppSettings”已过时:“This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings”
-------------------------------------------------
我用 ConfigurationManager.AppSettings["conn"] 取字串,
提示:错误 当前上下文中不存在名称“ConfigurationManager”
---------------------------------
我用的是VS2005开发环境,在帮助文档里有ConfigurationManager,但在输入代码时确实没有 ConfigurationManager提示可选。
怎么从app.config取连接字串?