Microsoft KB Archive/830118

= You receive a &quot;Timeout expired&quot; error message when you run a Visual Studio .NET 2003 application =

Article ID: 830118

Article Last Modified on 4/23/2007

-

APPLIES TO


 * Microsoft Visual Studio .NET 2003 Enterprise Architect
 * Microsoft Visual Studio .NET 2003 Enterprise Developer
 * Microsoft Visual Studio .NET 2003 Professional Edition
 * Microsoft Visual Studio .NET 2003 Academic Edition

-





SYMPTOMS
When you enable the SQL Server debugging feature in Microsoft Visual Studio .NET 2003, and then you run an application, you receive the following error message:

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.



CAUSE
The SQLClient Pool runs out of SqlInternalConnection objects.



WORKAROUND
To work around this problem, use one of the following methods:

Method 1
Change your project configuration to Release mode. To do this, follow these steps:
 * 1) In Visual Studio .NET, click Configuration Manager on the Build menu, and then click Release in the Active Solution Configuration list.
 * 2) On the Debug menu, click Start to run your application. Notice that you do not receive the error message that is mentioned in the &quot;Symptoms&quot; section.

Method 2
Change the Debug mode configuration properties of your project. To do this, follow these steps:
 * 1) In Visual Studio .NET, right-click your application in Solution Explorer, and then click Properties.
 * 2) In a Microsoft Visual Basic .NET project, click Debug under Configuration Properties, and then clear SQL Server debugging under Enable Debuggers.

In a Microsoft Visual C# .NET project, click Debugging under Configuration Properties, and then set the value of Enable SQL Debugging under Debuggers to False.



STATUS
This behavior is by design.



MORE INFORMATION
 Start Visual Studio .NET 2003. On the File menu, point to New, and then click Project. Click Visual Basic Projects or Visual C# Projects under Project Types, and then click Windows Application under Templates. Name the project SampleApplication. By default, Form1 is created. Add a button control to Form1.</li> Double-click the button that you added to Form1.</li>  Add the following code at the top of the Form1 class:

Visual Basic .NET
Imports System Imports System.Data.SqlClient

Visual C# .NET
using System; using System.Data.SqlClient; using System.Diagnostics; using System.Windows.Forms; </li>  In Visual Basic .NET, add the following code to the Click event of the Button1 button: Dim iCount As Integer = 1 Try Do       Dim sqlConn As New _ SqlConnection(&quot;Data Source=localhost;trusted_Connection=yes;initial catalog = Northwind&quot;) sqlConn.Open Trace.WriteLine(&quot;opening connection &quot; & CStr(iCount)) sqlConn.Close Trace.WriteLine(&quot;closing connection &quot; & CStr(iCount)) sqlConn.Dispose Trace.WriteLine(&quot;disposing connection &quot; & CStr(iCount)) iCount = iCount + 1 Loop Until iCount > 200 Catch ex As Exception Trace.WriteLine(ex.ToString) End Try In Visual C# .NET, add the following code to the Click event of the button1 button: int iCount = 1; try{ while (iCount <= 200){ SqlConnection sqlConn = new SqlConnection(&quot;Data Source=localhost;&quot; +       &quot;trusted_Connection=yes;initial catalog = Northwind&quot;); sqlConn.Open; Trace.WriteLine(&quot;opening connection &quot; + iCount.ToString); sqlConn.Close; Trace.WriteLine(&quot;closing connection &quot; + iCount.ToString); sqlConn.Dispose; Trace.WriteLine(&quot;disposing connection &quot; + iCount.ToString); iCount = iCount + 1; }  }catch(Exception ex){ Trace.WriteLine(ex.Message); } </li> On the Build menu, click Configuration Manager, and then click Debug in the Active Solution Configuration list.</li> In Solution Explorer, right-click SampleApplication, and then click Properties.</li> In a Visual Basic .NET project, click Debug under Configuration Properties, and then click to select SQL Server debugging under Enable Debuggers.

In a Visual C# .NET project, click Debugging under Configuration Properties, and then set the value of Enable SQL Debugging under Debuggers to True .</li> Click OK to close the SampleApplication Property Pages dialog box.</li> On the Debug menu, click Start to run your application.</li></ol>

<div class="references_section">