데이터베이스에 연결할 때 "ConfigurationManager가 선언되지 않았습니다"라는 오류 메시지를 어떻게 해결합니까?데이터베이스에 연결할 때 ConfigurationManager가 올바르게 선언됩니다.
SQLConnStr= ConfigurationManager.ConnectionStrings("SQLConnStr").ConnectionString
데이터베이스에 연결할 때 "ConfigurationManager가 선언되지 않았습니다"라는 오류 메시지를 어떻게 해결합니까?데이터베이스에 연결할 때 ConfigurationManager가 올바르게 선언됩니다.
SQLConnStr= ConfigurationManager.ConnectionStrings("SQLConnStr").ConnectionString
당신이 참조
당신이 폴더를 참고 문헌에`System.Configuration`
을 추가하는 것을 시도했다 : 여기
오류를 준다 코드의 라인입니다.프로젝트의 참조 폴더를 마우스 오른쪽 버튼으로 클릭 한 다음 참조 추가 ... 을 클릭 한 다음 System.Configuration을 확인한 다음 확인하십시오.
다음이에 양식에
변경하면 응용 프로그램 설정을
Imports System.Configuration
을 추가
이<connectionStrings>
<add name="SQLConnStr" connectionString="Data Source=HOTEL_MySQLSERVERR;Initial Catalog=GuestBooking;User ID=xyz;Password=xyz" providerName="System.Data.SqlClient" />
</connectionStrings>
// 앱 설정 이름과 연결 문자열 이름이 같은
해야합니다추가 이름 = "SQLConnStr"
ConnectionStrings ("SQLConnStr").
SQLConnStr= ConfigurationManager.ConnectionStrings("SQLConnStr").ConnectionString
이 한 번 봐 가지고 :
Fix the Name ‘ConfigurationManager’ is Not Declared Error
안부
난 당신이 제거하고 다시 "System.Configuration.dll" 을 참조를 추가하려고 할 필요가 있다고 생각을 프로젝트> Refrence 추가> .NET> System.Configuration을 선택하십시오.
Crimsonland는 이미 2 년 전에이 답변을 게시했습니다. 왜 다시 게시 했습니까? 귀하의 대답은이 새로운 질문에 어떤 새로운 정보를 추가합니까? –
포함되어 있습니다. 그 여전히 동일한 오류 – sheron
을 제공 할 수 있습니다. 당신은 또한 appconfig 코드를 추가 할 수 있습니다 .. – Crimsonland
시도 : Configuration.ConfigurationManager.ConnectionStrings ("SQLConnStr"). ConnectionString.ToString() – HardCode