Solved

System.InvalidOperationException occured in system.dll

Posted on 2006-11-07
5
516 Views
Last Modified: 2012-06-27
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 ????

0
Comment
Question by:niger007
  • 2
5 Comments
 
LVL 8

Assisted Solution

by:sabeesh
sabeesh earned 125 total points
ID: 17896048
check your connection object , once you have done the database operation CLOSE the connection object. this error is because  application’s connection pool reaches its limits. so it is waiting for a connection to close. check your code everywhere ensure that you are closing all connection objects

refer :http://www.dbazine.com/sql/sql-articles/charran2
0
 
LVL 35

Accepted Solution

by:
YZlat earned 125 total points
ID: 17897654
try

 cn.ConnectionTimeout = 0
0
 
LVL 35

Expert Comment

by:YZlat
ID: 17897656
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
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now