Bug #41034 .net parameter not found in the collection
Submitted: 25 Nov 2008 22:17 Modified: 9 Dec 2008 16:02
Reporter: Manuel Navas Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:5.2.5 OS:Windows
Assigned to: CPU Architecture:Any
Tags: not found in the collection, parameter not found in the collection

[25 Nov 2008 22:17] Manuel Navas
Description:
When I write a SP and leave a white space in my parameters list:
myparameter1 decimal (8,2) or
myparameter2 char (10)
See the white spaces? when I call the Stored Procedure from .net, it throws an exception.
The really annoying thing is that if you call the stored procedure from the Query Analyzer or mysql> shell, it works just fine, but when you call it from .Net, it throws an exception saying: Parameter '0' not found in the collection, this is very frustrating because it doesnt give you a hint where to look for.

How to repeat:
Create a stored procedure and in your parameters list, leave a white space:
myparameter decimal (8,2)
then call it from .Net

Suggested fix:
To use the same way to call a stored procedure as the Query Analyzer does.
[3 Dec 2008 19:07] Reggie Burnett
Correction, not verified.  doesn't seem to fail on current 5.2 code.  Here is the code I am using to try and reproduce.

execSQL("CREATE PROCEDURE spTest(myparam decimal (8,2)) BEGIN SELECT 1; END");

MySqlCommand cmd = new MySqlCommand("spTest", conn);
cmd.Parameters.Add("?myparam", MySqlDbType.Decimal).Value = 20;
cmd.CommandType = CommandType.StoredProcedure;
object o = cmd.ExecuteScalar();
Assert.AreEqual(1, o);

This works as expected.
[3 Dec 2008 19:10] Reggie Burnett
Nevermind.  I was running the test under the wrong setup.  I have verified that it fails.
[3 Dec 2008 19:31] 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/60527
[3 Dec 2008 19:39] Reggie Burnett
fixed in 5.2.6.  Problem not present in 6.0+
[9 Dec 2008 16:02] Tony Bedford
An entry was added to the 5.2.6 changelog:

If a Stored Procedure contained spaces in its parameter list, and was then called from Connector/NET, an exception was generated. However, the same Stored Procedure called from the MySQL Query Analyzer or the MySQL Client worked correctly.

The exception generated was:

Parameter '0' not found in the collection.