Why does this fail

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have found a resource leak in v1.1 of the framework

With sql debugging on the following code does not return the closed connections to the connection pool as it should
This might happen at other times also, but on my development machine is always happens

Operating System XP Professiona
FrameWork 1.
Visual Studio 200
SQL Debugging = Enable

Witn Debugging Disabled, or on the 1.0 framework this code runs sucessfully

Anyone know of any documentation from Microsoft on this issue

using System
using System.Data.SqlClient

namespace ConsoleApplication

/// <summary
/// Summary description for Class1
/// </summary

class GetDat


/// <summary
/// The main entry point for the application
/// </summary
[STAThread
static void Main(string[] args

Test t = new Test()
t.GetDataResults()




class Tes

public void GetDataResults(

SqlConnection mConn
mConn = new SqlConnection("Persist Security Info=False;User ID=sa;Password=password;Initial Catalog=NamedDatbase;Data Source=ServerName;Packet Size=4096;Workstation ID=" + System.Environment.MachineName)
SqlCommand comm = new SqlCommand("SELECT * FROM Client WHERE CustID=2",mConn)
SqlDataReader reader
for(int count = 0; count < 5000; count++

mConn.Open()
reader = comm.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
reader.Read()
reader.Close()
 
Puzzled,
Connection pooling is on by default, try adding Pooling=false to your
connection string.

hope this helps,
--
Angel Saenz-Badillos [MS] Managed Providers
This posting is provided "AS IS", with no warranties, and confers no
rights.Please do not send email directly to this alias.
This alias is for newsgroup purposes only.

Puzzled said:
I have found a resource leak in v1.1 of the framework.

With sql debugging on the following code does not return the closed
connections to the connection pool as it should.
This might happen at other times also, but on my development machine is always happens.

Operating System XP Professional
FrameWork 1.1
Visual Studio 2003
SQL Debugging = Enabled

Witn Debugging Disabled, or on the 1.0 framework this code runs sucessfully.

Anyone know of any documentation from Microsoft on this issue?


using System;
using System.Data.SqlClient;

namespace ConsoleApplication1
{
/// <summary>
/// Summary description for Class1.
/// </summary>

class GetData
{

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Test t = new Test();
t.GetDataResults();
}


}
class Test
{
public void GetDataResults()
{
SqlConnection mConn;
mConn = new SqlConnection("Persist Security Info=False;User
ID=sa;Password=password;Initial Catalog=NamedDatbase;Data
Source=ServerName;Packet Size=4096;Workstation ID=" +
System.Environment.MachineName);
 
Back
Top