Timeout expired for connection pooling

bubberz

New member
Joined
Apr 15, 2005
Messages
3
Programming Experience
3-5
I'm getting 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.

Not sure why, since I'm trying to close the connection right when I'm done, and the timeout is set to "30".
VB.NET:
Select Case DBselected
            Case "DB8"
                Try
                    Dim sCon1 As New SqlConnection
                    sCon1.ConnectionString = ConfigurationSettings.AppSettings("db8")
                    Session("DBDDL") = sCon1.ConnectionString.ToString()
                    sCon1.Open()
                    Dim cmd As New SqlCommand("[usp_Security]", sCon1)
                    cmd.CommandType = System.Data.CommandType.StoredProcedure
                    cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@IDNumber", System.Data.SqlDbType.NVarChar, 50))
                    cmd.Parameters("@IDNumber").Value = Session("User")
                    Dim DR As SqlDataReader = cmd.ExecuteReader
                    If DR.HasRows = False Then
                        
                        btnSwitchboard1.Enabled = False
                        lblnotice.Visible = True
                        lblnotice.Text = "The IDNumber, " & strIDNumber & ", doesn't exist in the database for access permission!"
                    Else
                        btnSwitchboard1.Enabled = True
                        lblnotice.Visible = False
                    End If
                    DR.Close()
                    DR = Nothing
                Catch ex As Exception
                    lblStatus.Text = "Error building IDNumber:  " & ex.Message
                Finally
                    sCon1.Close()
                End Try
            Case "DB1"
                Try
                   
                    Dim sCon1 As New SqlConnection
                    sCon1.ConnectionString = ConfigurationSettings.AppSettings("db1")
                    Session("DBDDL") = sCon1.ConnectionString.ToString()
                    sCon1.Open()
                    Dim cmd As New SqlCommand("[usp_Security]", sCon1)
                    cmd.CommandType = System.Data.CommandType.StoredProcedure
                    cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@IDNumber", System.Data.SqlDbType.NVarChar, 50))
                    cmd.Parameters("@IDNumber").Value = Session("User")
                    Dim DR As SqlDataReader = cmd.ExecuteReader
                    If DR.HasRows = False Then
                        btnSwitchboard1.Enabled = False
                        lblnotice.Visible = True
                        lblnotice.Text = "The IDNumber, " & strIDNumber & ", doesn't exist in the database for access permission!"
                    Else
                        
                        btnSwitchboard1.Enabled = True
                        lblnotice.Visible = False
                    End If
                    DR.Close()
                    DR = Nothing
                Catch ex As Exception
                    lblStatus.Text = "Error building IDNumber:  " & ex.Message
                Finally
                    sCon1.Close()
                End Try
            Case "DB2"
                Try
                   
                    Dim sCon1 As New SqlConnection
                    sCon1.ConnectionString = ConfigurationSettings.AppSettings("db2")
                    Session("DBDDL") = sCon1.ConnectionString.ToString()
                    sCon1.Open()
                    Dim cmd As New SqlCommand("[usp_Security]", sCon1)
                    cmd.CommandType = System.Data.CommandType.StoredProcedure
                    cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@IDNumber", System.Data.SqlDbType.NVarChar, 50))
                    cmd.Parameters("@IDNumber").Value = Session("User")
                    Dim DR As SqlDataReader = cmd.ExecuteReader
                    If DR.HasRows = False Then
                        
                        btnSwitchboard1.Enabled = False

                        lblnotice.Visible = True
                        lblnotice.Text = "The IDNumber, " & strIDNumber & ", doesn't exist in the database for access permission!"
                    Else
                        
                        btnSwitchboard1.Enabled = True
                        lblnotice.Visible = False
                    End If
                    DR.Close()
                    DR = Nothing
                Catch ex As Exception
                    lblStatus.Text = "Error building IDNumber:  " & ex.Message
                Finally
                    sCon1.Close()
                End Try
            Case "DB3"
                Try
                    
                    Dim sCon1 As New SqlConnection
                    sCon1.ConnectionString = ConfigurationSettings.AppSettings("db3")
                    Session("DBDDL") = sCon1.ConnectionString.ToString()
                    sCon1.Open()
                    Dim cmd As New SqlCommand("[usp_Security]", sCon1)
                    cmd.CommandType = System.Data.CommandType.StoredProcedure
                    cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@IDNumber", System.Data.SqlDbType.NVarChar, 50))
                    cmd.Parameters("@IDNumber").Value = Session("User")
                    Dim DR As SqlDataReader = cmd.ExecuteReader
                    If DR.HasRows = False Then
                        btnSwitchboard1.Enabled = False
                        lblnotice.Visible = True
                        lblnotice.Text = "The IDNumber, " & strIDNumber & ", doesn't exist in the database for access permission!"
                    Else
                       
                        btnSwitchboard1.Enabled = True
                        lblnotice.Visible = False
                    End If
                    DR.Close()
                    DR = Nothing
                Catch ex As Exception
                    lblStatus.Text = "Error building IDNumber:  " & ex.Message
                Finally
                    sCon1.Close()
                End Try
            Case "DB4"
                Try
                    
                    Dim sCon1 As New SqlConnection
                    sCon1.ConnectionString = ConfigurationSettings.AppSettings("db4")
                    Session("DBDDL") = sCon1.ConnectionString.ToString()
                    sCon1.Open()
                    Dim cmd As New SqlCommand("[usp_Security]", sCon1)
                    cmd.CommandType = System.Data.CommandType.StoredProcedure
                    cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@IDNumber", System.Data.SqlDbType.NVarChar, 50))
                    cmd.Parameters("@IDNumber").Value = Session("User")
                    Dim DR As SqlDataReader = cmd.ExecuteReader
                    If DR.HasRows = False Then
                        
                        btnSwitchboard1.Enabled = False
                        lblnotice.Visible = True
                        lblnotice.Text = "The IDNumber, " & strIDNumber & ", doesn't exist in the database for access permission!"
                    Else
                        
                        btnSwitchboard1.Enabled = True
                        lblnotice.Visible = False
                    End If
                    DR.Close()
                    DR = Nothing
                Catch ex As Exception
                    lblStatus.Text = "Error building IDNumber:  " & ex.Message
                Finally
                    sCon1.Close()
                End Try
 
Back
Top