C# connection string in web.config file

心已入冬 提交于 2019-12-04 03:40:33
Kyle Sonaty
System.Web.Configuration.WebConfigurationManager.ConnectionStrings["YouConnStringName"].ConnectionString;

This requires references to System.Configuration.dll and System.Web.dll.

From comment on http://msdn.microsoft.com/en-us/library/ms178411.aspx

string c = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["myconnectionstringname"].ConnectionString;

Requires your project to reference to System.Web and System.Configuration. I had to actually add a reference to "System.Configuration" not just add a Using.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!