Imports System.Data.SqlClient
Module Module1
Sub Main()
Dim iCount As Integer = 1
Try
Do
Dim sqlConn As New _
SqlConnection("Data Source=localhost;trusted_Connection=yes;initial catalog = MyDatabase;max pool size =100;")
sqlConn.Open()
Trace.WriteLine("opening connection " & CStr(iCount))
'sqlConn.Close()
'Trace.WriteLine("closing connection " & CStr(iCount))
'sqlConn.Dispose()
'Trace.WriteLine("disposing connection " & CStr(iCount))
iCount = iCount + 1
Loop Until iCount > 20000
Catch ex As Exception
Trace.WriteLine(ex.ToString)
End Try
End Sub
End Module
If I run this code, this test application will open 115 database connections before it throws an exception The timeout period elapsed prior to obtaining a connection from the pool. But there are only 100 connections in the application pool. How is this possible?
source
share