How can I solve a max pool size - ASP.NET

927 views Asked by At
Public Function QueryDataSet(ByVal strSQL As String) As DataSet
    Dim ds As New DataSet
    Dim dtAdapter As New SqlDataAdapter
    objConn = New SqlConnection
    With objConn
        .ConnectionString = strConn
        .Open()
    End With
    objCmd = New SqlCommand
    With objCmd
        .Connection = objConn
        .CommandText = strSQL
        .CommandType = CommandType.Text
    End With
    dtAdapter.SelectCommand = objCmd
    dtAdapter.Fill(ds)

    objConn.Close()
    objConn.Dispose()
    SqlConnection.ClearPool(objConn)
    objConn = Nothing
    Return ds 
End function

The above is in the class

How can I fix my function that solve the Max Pool Size is Full on my server?

Please Help me.

1

There are 1 answers

3
Arjun Singh On

Use following code

Public Function QueryDataSet(ByVal strSQL As String) As DataSet
    Dim ds As New DataSet
    Dim dtAdapter As New SqlDataAdapter
Try
    objConn = New SqlConnection
    With objConn
        .ConnectionString = strConn
        .Open()
    End With
    objCmd = New SqlCommand
    With objCmd
        .Connection = objConn
        .CommandText = strSQL
        .CommandType = CommandType.Text
    End With
    dtAdapter.SelectCommand = objCmd
    dtAdapter.Fill(ds)

    objConn.Close()
    objConn.Dispose()
    SqlConnection.ClearPool(objConn)
    objConn = Nothing

Catch ex As Exception
MessageBox.Show(ex.Message)

Finally

    objConn.Close()
    objConn.Dispose()
    SqlConnection.ClearPool(objConn)
    objConn = Nothing

End Try

    Return ds 
End function

or Add MaxPoolSize={123} in the Connection String.