如何获取连接字符串从web.config [英] How to get Connection String From the Web.config
问题描述
可能重复:结果
<一href=\"http://stackoverflow.com/questions/1737393/in-c-sharp-how-can-i-read-a-connection-string-stored-in-my-web-config-file-con\">In C#中,我怎么能读取存储在我的web.config文件中的连接字符串连接字符串?
我使用的SqlConnection类连接到SQL Server数据库。其中一个构造函数,对此类需要一个连接字符串参数...什么是摆脱web.config文件中所需的信息的最简单方法....
I am using the SqlConnection class to connect to a sql server database. One of the constructors for this class required a connection string argument...What is the easiest way to get the required information from the web.config file....
推荐答案
使用<一个href=\"http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.connectionstrings.aspx\"相对=nofollow> ConfigurationManager.ConnectionStrings 采集读取web.config中的连接字符串。
Use ConfigurationManager.ConnectionStrings collection to read connection string from web.config.
这篇关于如何获取连接字符串从web.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!