Bug #7398 MySqlParameterCollection doesn't allow parameters without filled in names
Submitted: 18 Dec 2004 8:15 Modified: 25 Feb 2005 23:40
Reporter: [ name withheld ] Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version: OS:Any (Any)
Assigned to: Reggie Burnett CPU Architecture:Any

[18 Dec 2004 8:15] [ name withheld ]
Description:
   MySqlCommand.Parameters collection doesn't allow to add parameters without filled in Name property. The MS SQL, Oracle and ODBC providers for ADO.NET allows to add parameters without name and to set the name after that (prior execution). This makes the MySql provider a little bit incompatible with the other providers.

How to repeat:
MySqlCommand cmd = ....
cmd.Parameters.Add(new MySqlParameters())

Suggested fix:
I have removed the checks for name from 

int Add( object value )    and
int Add( MySqlParameter value ) 

methods in MySqlParameterCollection class. The existence of name can be checked before execution and for such reason I added the following loop in the MySqlCommand.CheckState method:

foreach (MySqlParameter param in parameters)
{
	if (param.ParameterName == null || 
                 param.ParameterName == String.Empty)
                       throw new MySqlException("Parameters must be named");
}
[17 Jan 2005 1:22] Paul Wilson
Support for the generic ADO.NET interfaces, necessary to write non-provider specific code, requires the IDbCommand.CreateParameter method to allow creation of parameters before they are named -- so this is a critical bug to a lot of existing code.
[18 Jan 2005 0:15] Paul Wilson
Alright, my apologies for over-reacting.  Its not as bad as I first thought.
[25 Feb 2005 23:40] Reggie Burnett
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html