문제

페이지 뒤에있는 코드에서 web.config 파일에 저장된 연결 문자열에 어떻게 액세스합니까?

도움이 되었습니까?

해결책

System.Web.Configuration.WebConfigurationManager.ConnectionStrings["YouConnStringName"].ConnectionString;

System.configuration.dll 및 System.Web.dll에 대한 참조가 필요합니다.

다른 팁

의견에서 http://msdn.microsoft.com/en-us/library/ms178411.aspx

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

System.Web 및 System.Configuration을 참조하도록 프로젝트가 필요합니다. 실제로 사용을 추가하는 것이 아니라 "System.configuration"에 대한 참조를 추가해야했습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top