에서 DB에 호출 후 종료되지 않는다 닫히지 마라. 처음으로 페이지를 요청할 때 데이터를 잘 볼 수 있습니다. 다시로드에 나는 다음과 같은 오류 얻을 : 마지막으로연결 내가 ASP.NET에서 저장 프로 시저를 호출하는 일반적인 방법이 ASP.NET
The connection was not closed. The connection's current state is open. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The connection was not closed. The connection's current state is open.
Source Error:
Line 35: Line 36: } Line 37: sql.Connection.Open(); Line 38: iReader = sql.ExecuteReader(CommandBehavior.CloseConnection); Line 39: sql.Dispose();
를 내가) sql.Connection.Close를 (넣어 경우; before sql.Dispose(); 이미 닫혀 있기 때문에 iReader를 읽을 수 없다는 오류가 나타납니다.
분명히 연결을 잘못 닫고 있습니다. 누군가 올바른 방향으로 나를 가리킬 수 있습니까?
나는 "자원을 적절하게 정리하는 소비자의 책임"이라는 귀하의 접근 방식에 동의하지만, 일반적으로 이에 의존하지 않으므로 소비자는이 작업을하기에는 너무 게으른 것입니다. –
감사합니다. 내 while 루프 다음에 내 consumingmethod에 iReader.Close()를 추가했습니다. – RedWolves
ExecuteStoredProc에서 생성하는 연결을 닫고 처리 할 필요가 없습니까? –