Bug #34460 Connections doesn't close
Submitted: 11 Feb 2008 15:16 Modified: 1 Mar 2008 12:01
Reporter: Martin Wählby
Status: Closed
Category:Connector/Net Severity:S2 (Serious)
Version:5.1.3-5.2 OS:Microsoft Windows
Assigned to: Target Version:
Tags: pooling, Close Connection

[11 Feb 2008 15:16] Martin Wählby
Description:
I'm using Connector/Net togheter with asp.net 2.0. I have problems with that my
connections doesn't close. For each time I reload my page I get a new connection that
doesn't close until max_user_connections is reached. I use this code:

<asp:SqlDataSource ID="DS_processlist" runat="server" DataSourceMode="DataReader" 
ConnectionString="Data Source=**;Database=**;User ID=**;Password=**;Pooling=false"
ProviderName="MySql.Data.MySqlClient" SelectCommand="show
processlist"></asp:SqlDataSource>
<asp:DataGrid ID="DG" runat="server" DataSourceID="DS_processlist"
AutoGenerateColumns="true"></asp:DataGrid>

When I bind my data in codebehind by myself and closes the connection myself everything
works perfect and my connections is closed:

MySqlConnection conn = new MySqlConnection("Data Source=**;Database=**;User
ID=**;Password=**;Pooling=false");
        cmd = new MySqlCommand("show processlist", conn);
        cmd.Connection.Open();
        dr = cmd.ExecuteReader();
        DG.DataSource = dr;
        DG.DataBind();
        cmd.Connection.Close();

I've tried both with Pooling enabled and disabled, nothing seems to help.

Please check this out!

How to repeat:
This doesn't work:

<asp:SqlDataSource ID="DS_processlist" runat="server" DataSourceMode="DataReader" 
ConnectionString="Data Source=**;Database=**;User ID=**;Password=**;Pooling=false"
ProviderName="MySql.Data.MySqlClient" SelectCommand="show
processlist"></asp:SqlDataSource>
<asp:DataGrid ID="DG" runat="server" DataSourceID="DS_processlist"
AutoGenerateColumns="true"></asp:DataGrid>

But this works:
MySqlConnection conn = new MySqlConnection("Data Source=**;Database=**;User
ID=**;Password=**;Pooling=false");
        cmd = new MySqlCommand("show processlist", conn);
        cmd.Connection.Open();
        dr = cmd.ExecuteReader();
        DG.DataSource = dr;
        DG.DataBind();
        cmd.Connection.Close();
[1 Mar 2008 1:10] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/43248
[1 Mar 2008 1:11] Reggie Burnett
Fixed in 5.1.6 and 5.2.2
[1 Mar 2008 12:01] MC Brown
A note has been added to the 5.1.6 and 5.2.2 changelogs: 

When using SqlDataSource to open a connection, the connection would not automatically be
closed when access had completed.