코드를 보지 않고는 명확한 답을 내릴 수 없습니다. 데이터베이스 연결을 신속하게 정리하지 않는 경우에 은 일 수 있습니다.
당신이 뭔가를 한 경우 :
While(True)
Dim con as new SqlConnection(connectionString)
con.Open()
Dim cmd as New SqlCommand("usp_getJob", con)
cmd.CommandType = CommandType.StoredProcedure
Dim dr as SqlDataReader = cmd.ExecuteReader(CommandBehavior.SingleResult Or CommandBehavior.SingleRow Or CommandBehavior.CloseConnection)
If(dr.Read())
DoSomething(dr)
Else
Thread.Sleep(10)
End If
End While
... 그때는 빨리 그들 자신에 의해 멀리 갈 것보다 연결을 엽니 다.
여러 대체있다, 나는 연결이 가능한 한 빨리 연결 풀에 반환 할 수 있도록 Using
블록을 사용하여 옹호 것 :
While(True)
Using con as new SqlConnection(connectionString)
con.Open()
Using cmd as New SqlCommand("usp_getJob", con)
cmd.CommandType = CommandType.StoredProcedure
Using dr as SqlDataReader = cmd.ExecuteReader(CommandBehavior.SingleResult Or CommandBehavior.SingleRow Or CommandBehavior.CloseConnection)
If(dr.Read())
DoSomething(dr)
dr.Close()
Else
Thread.Sleep(10)
End If
End Using
End Using
End Using
End While
이 다음 SqlDataReader
에 Dispose()
를 호출합니다 SqlConnection
을 및 SqlCommand
- 처음 두 중 하나는 연결이
어떤 일이 벌어지는 지 알 수 있도록 코드 스 니펫을 게시 할 가능성이 있습니까? – twlichty