Bug #57874 MySqlHelper.ExecuteReader fails when called with ConnectionString
Submitted: 31 Oct 2010 14:53 Modified: 2 Nov 2010 14:33
Reporter: Holger Mueller Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:6.3.5 OS:Any
Assigned to: CPU Architecture:Any
Tags: ConnectionString, MySqlHelper.ExecuteReader, regression

[31 Oct 2010 14:53] Holger Mueller
Description:
You can call MySqlHelper.ExecuteReader() either with a MySqlConnection parameter or with string parameter containing the connection-string.
In the latter case ExecuteReader should create an connection itself.
Since 6.3.5 this does not work anymore, reverting to 6.3.4 solves the problem.

How to repeat:
Execute the following code. As you can see it calls two MySqlDataReader (myReaderA and myReaderB) both with the same SQL-command, both with MySqlHelper.ExecuteReader. The first uses the manually initiated connection (myConnection) and the second one just passes the connectionString to the function. The code fails at myReaderB.Read() with the error message 'Invalid attempt to Read when reader is closed."

        using MySql.Data.MySqlClient;

        private void test()
        {
            MySqlConnection myConn;
            MySqlConnectionStringBuilder myCsb;
            MySqlDataReader myReaderA;
            MySqlDataReader myReaderB;

            myCsb = new MySqlConnectionStringBuilder();
            myCsb.UserID = "root"; myCsb.Password = ""; myCsb.Server = "127.0.0.1"; myCsb.Database = "mysql";

            myConn = new MySqlConnection(myCsb.GetConnectionString(true));
            myConn.Open();

            myReaderA = MySqlHelper.ExecuteReader(myConn, "SELECT * FROM user");
            myReaderB = MySqlHelper.ExecuteReader(myCsb.ConnectionString, "SELECT * FROM user");

            myReaderA.Read(); Console.WriteLine(myReaderA.GetString(1));
            myReaderB.Read(); Console.WriteLine(myReaderB.GetString(1));

            myReaderA.Close(); myReaderB.Close(); myConn.Close();
        }

My test environment is German Win7 x64, VS2010, MySql 5.5.6 rc x64.
I also tried to use myCsb.GetConnectionString(true) instead of myCsb.ConnectionString but no difference.
[2 Nov 2010 8:15] Mikhail Oleynik
There is the same issue in #57501
[2 Nov 2010 14:33] Tonci Grgin
Duplicate of Bug#57501 which I already verified.