I have an app that I'm developing on my PC and testing on a server. I can run the app in the Visual Studio IDE all day long on my PC and have no trouble with the SQL connection. When I installed the app on a server, the connections don't get dropped, so when I run the app I get the following error:
----------------
Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. at System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) at System.Data.SqlClient.SqlConnection.Open()
----------------
The funny thing is, I can still run the app from the VS IDE on my PC and have no trouble getting a SQL connection! Maybe the .Net garbage collector works differently when you run the app from the IDE?
What would happen if I didn't use connection pooling? Would the connections be closed more efficiently? Should the SQL server itself be closing the connections after some period of time, or is that all handled by .Net?
This is an intranet-based app and I don't expect a very large user base.
Below is a sample of a typical function in the app:
----------------
Public Sub DisableUser(ByVal intUserID As Integer)
Dim objCommand As New SqlCommand(SP_DISABLE_USER, objConnection)
Try
objCommand.CommandType = CommandType.StoredProcedure
objCommand.Parameters.Add("@UserID", intUserID)
objCommand.ExecuteNonQuery()
Catch ex As Exception
Err.Raise(ERR_DISABLE_USER, , "Error Disabling User (clsData.DisableUser): " & ex.Message & " " & ex.StackTrace)
Finally
objConnection.Dispose()
objCommand.Dispose()
End Try
End Sub
----------------
As you can see, I'm explicitly closing everything in my Finally block.
Thanks in advance for your help!
----------------
Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. at System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) at System.Data.SqlClient.SqlConnection.Open()
----------------
The funny thing is, I can still run the app from the VS IDE on my PC and have no trouble getting a SQL connection! Maybe the .Net garbage collector works differently when you run the app from the IDE?
What would happen if I didn't use connection pooling? Would the connections be closed more efficiently? Should the SQL server itself be closing the connections after some period of time, or is that all handled by .Net?
This is an intranet-based app and I don't expect a very large user base.
Below is a sample of a typical function in the app:
----------------
Public Sub DisableUser(ByVal intUserID As Integer)
Dim objCommand As New SqlCommand(SP_DISABLE_USER, objConnection)
Try
objCommand.CommandType = CommandType.StoredProcedure
objCommand.Parameters.Add("@UserID", intUserID)
objCommand.ExecuteNonQuery()
Catch ex As Exception
Err.Raise(ERR_DISABLE_USER, , "Error Disabling User (clsData.DisableUser): " & ex.Message & " " & ex.StackTrace)
Finally
objConnection.Dispose()
objCommand.Dispose()
End Try
End Sub
----------------
As you can see, I'm explicitly closing everything in my Finally block.
Thanks in advance for your help!