Bug #13114 ASP.NET DB connections remain established after Close()
Submitted: 11 Sep 2005 22:38 Modified: 16 Oct 2005 7:40
Reporter: Darren Bounds Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:1.0.5 OS:Windows (Windows XP SP2)
Assigned to: Assigned Account CPU Architecture:Any

[11 Sep 2005 22:38] Darren Bounds
Description:
Using Visual Studio 2003 with .net MySQL connector 1.0.5 for .NET 1.1 (Windows XP SP2)
Database: MySQL 4.1.14-NT (Windows XP SP2)
Language: C# (ASP.NET 1.1)
Web server: IIS 5.1

Quite simply, calls to the MySqlConnection.Close() method do not close connections to the local database through ASP.NET (C#). The same code in a Console or WinForms application closes it correctly.

We have gone so far as to open the connection and close it immediately. The state of the object shows Closed, however looking at netstat shows the connections are indeed still established. Over time, this leads to the database reaching it's connection limit.

How to repeat:
Create an ASP.NET web form applications with the following code:

private void Page_Load(object sender, System.EventArgs e)
{
	string ConnectionString = string.Format(
		"Database=MyDB;"
		+ "Allow Batch=true;"
		+ "Server=localhost;"
		+ "UID=root;"
		+ "PWD=testing;");
	MySqlConnection DbConn = new MySqlConnection();

	DbConn.ConnectionString = ConnectionString;
	Response.Write("Opening DB Connection<br>");
	DbConn.Open();	
	Response.Write("Connection Status: " + DbConn.State.ToString() + "<br>");
	Response.Write("Closing DB Connection<br>");
	DbConn.Close();
	Response.Write("Connection Status: " + DbConn.State.ToString() + "<br>");
}
[13 Sep 2005 2:35] Darren Bounds
Sorry, I meant to add, this is with connection pooling enabled. Refreshing the same ASP.NET page creates a new MySQL connection without closing the old.
[16 Sep 2005 7:40] Vasily Kishkin
Could you please create and attach simple test case (ASP file) ?
[16 Oct 2005 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".