0

asp 서버에서 아래와 같이 ExecuteScalar, ExecuteReaderExecuteNonQuery을 실행 한 후 SQL Server에 대해 오류가 발생합니다. 오류는 때로 만 발생하며 항상 볼 수는 없습니다. 따라서이 오류가 발생하는 이유는 누구나 알 수 있습니까? 그것을 해결하는 방법?ASP 서버에서 SQL Server 연결에 발생하는 오류

System.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)

at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParserStateObject.WriteSni()
at System.Data.SqlClient.TdsParserStateObject.WritePacket(Byte flushMode)
at System.Data.SqlClient.TdsParserStateObject.ExecuteFlush()
at System.Data.SqlClient.TdsParser.TdsExecuteSQLBatch(String text, Int32 timeout, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader()
at WinMsg.Page_Load(Object sender, EventArgs e)

+0

올바른 연결 문자열이 있는지 확인하십시오. 및 액세스 권한. –

+0

@Ravi 그는 데이터베이스에 성공적으로 호출 한 후 오류가 발생한다고 말합니다. 나는 그것들이 연결 문자열을 변경하고 그것과 같은 모든 것을 쓸데없이 액세스하는 권한을 상상할 수 없다. – jadarnel27

+0

오류가 몇 번 밖에 없기 때문에 연결 문자열이 적합합니다. –

답변

0

DataReader을 언급했습니다. 정확하게 닫았는지 확인하십시오. 나는 그것이 아직 열려 있고 더 이상의 데이터베이스 조작을 막을 것으로 생각한다. MSDN에서

:

While the SqlDataReader is in use, the associated SqlConnection is busy serving the SqlDataReader. While in this state, no other operations can be performed on the SqlConnection other than closing it. This is the case until you call the SqlDataReader.Close method. If the SqlDataReader is created with CommandBehavior set to CloseConnection, closing the SqlDataReader closes the connection automatically.

또한 SqlConnection 개체가 닫혀 있고 사용 후 제대로 설치되어 있는지 확인하십시오.