Bug #14823 Pooling error
Submitted: 10 Nov 2005 11:58 Modified: 6 Nov 2007 15:24
Reporter: Petr Weissar Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / NET Severity:S4 (Feature request)
Version:1.0.6 OS:Windows (Windows)
Assigned to: CPU Architecture:Any

[10 Nov 2005 11:58] Petr Weissar
Description:
I use .NET Connector with ASP.NET 2.0 (C#) compiled uder VisualStudio 2005. When I repeat sequence of MySqlConnection.Open() and execute SELECT and MySqlConnection.Close() many times in one script page the pooling mechanism doesn't work. Open() always generate SHOW VARIABLES, SET NAMES and so on. Driver is always created again, is not pooled.
I have found error in the function NativeDriver.Ping() on line with ExecuteCommand(DBCmd.PING, null, 0), because the second parameter is declared as byte[] and required operation emitted exception "Array cannot be null.". This exception is in code of function Ping() refused and function returns false - pooling cannot work !

How to repeat:
Fragments of ASP.NET C# code:

...
public int GetSQLValue()
{
  MySqlConnection conn = new MySqlConnection("...connection_string...");
  conn.Open();
  MySqlCommand cmd = new MySqlCommand("SELECT COUNT(*) FROM tbl", conn);
  int value = cmd.ExecuteScalar();
  conn.Close();
  return value;
}
...
Page ... On_Load(...)
{
  ...
  for (int i = 0; i < 10; i++)
  {
    ...
    Response.Write(GetSQLValue().ToString);
    ...
  }
  ...
}

******************************
Modification NativeDriver.cs - shows executed SQL commands:
added line:
System.Web.HttpContext.Current.Trace.Write("MySQL " + cmd.ToString(), Encoding.GetString(bytes, 0, length));

to function:
private void ExecuteCommand( DBCmd cmd, byte[] bytes, int length )
[6 Nov 2007 15:24] Reggie Burnett
This an old bug report and we believe this is fixed now.