web.config文件中的C#连接字符串

fla*_*404 8 .net c# connection-string web-config visual-studio-2008

在我的代码隐藏页面中,如何访问存储在web.config文件中的连接字符串?

小智 21

System.Web.Configuration.WebConfigurationManager.ConnectionStrings["YouConnStringName"].ConnectionString;
Run Code Online (Sandbox Code Playgroud)

这需要引用System.Configuration.dll和System.Web.dll.