You receive a "Timeout expired" error message when you run a Visual Studio .NET 2003 application

Article translations Article translations
Article ID: 830118 - View products that this article applies to.
Expand all | Collapse all

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 "Symptoms" 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

  1. Start Visual Studio .NET 2003.
  2. On the File menu, point to New, and then click Project.
  3. Click Visual Basic Projects or Visual C# Projects under Project Types, and then click Windows Application under Templates.
  4. Name the project SampleApplication. By default, Form1 is created.
  5. Add a button control to Form1.
  6. Double-click the button that you added to Form1.
  7. 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;
  8. 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("Data Source=localhost;trusted_Connection=yes;initial catalog = Northwind")
    		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 > 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("Data Source=localhost;" +
     		"trusted_Connection=yes;initial catalog = Northwind");
     		sqlConn.Open();
     		Trace.WriteLine("opening connection " + iCount.ToString());
     		sqlConn.Close();
     		Trace.WriteLine("closing connection " + iCount.ToString());
     		sqlConn.Dispose();
     		Trace.WriteLine("disposing connection " + iCount.ToString());
     		iCount = iCount + 1;
     	}  
     }catch(Exception ex){
     	Trace.WriteLine(ex.Message);
     }
  9. On the Build menu, click Configuration Manager, and then click Debug in the Active Solution Configuration list.
  10. In Solution Explorer, right-click SampleApplication, and then click Properties.
  11. 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.
  12. Click OK to close the SampleApplication Property Pages dialog box.
  13. On the Debug menu, click Start to run your application.

REFERENCES

For more information about pooling in MDAC, visit the following Microsoft Developer Network (MSDN) Web site:
http://msdn2.microsoft.com/en-us/library/ms810829.aspx

Properties

Article ID: 830118 - Last Review: April 23, 2007 - Revision: 1.5
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
Keywords: 
kbconnpts kbideproject kbsqlclient kbprb KB830118

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com