System.Web.Configuration.WebConfigurationManager.ConnectionStrings["YouConnStringName"].ConnectionString;
这需要引用System.Configuration.dll和System.Web.dll.