Link to home
Start Free TrialLog in
Avatar of niger007
niger007

asked on

System.InvalidOperationException occured in system.dll

Hi Foks,

My vb.net application requires sql connection to exceute some tasks. I am experiencing the below error message intermittently.. and here is my connection code.

Imports System.Data.SqlClient
Public Class SqlHelper

    Public Function GetConnection() As SqlConnection
        Dim cn As New SqlConnection
        With cn
            .ConnectionString = "Data Source = .;Initial Catalog=xxxxxxx;Integrated security=SSPI"
            .Open()
        End With

        Return cn
    End Function

End Class

The detailed exception message is

System.InvalidOperationException occured in System.data.dll

Additional Information: Time out 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.

How should i get rid of this situation ????

SOLUTION
Avatar of sabeesh
sabeesh
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of YZlat
YZlat
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Imports System.Data.SqlClient
Public Class SqlHelper

    Public Function GetConnection() As SqlConnection
        Dim cn As New SqlConnection
        With cn
            .ConnectionString = "Data Source = .;Initial Catalog=xxxxxxx;Integrated security=SSPI"
            .ConnectionTimeout = 0
            .Open()
        End With

        Return cn
    End Function

End Class