Bug #27187 cmd.Parameters.RemoveAt("Id") will cause an error if the last item is requested
Submitted: 15 Mar 2007 17:56 Modified: 26 Mar 2007 6:22
Reporter: Paul van Keulen Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:5.0.5 OS:Windows (WinXP)
Assigned to: CPU Architecture:Any
Tags: Parameter;RemoveAt;GetParameter;IndexOf

[15 Mar 2007 17:56] Paul van Keulen
Description:
Hello 

Something with removing parameters in the MySql .NET driver version 5.0.5 is not working correctly. 

I have a MySqlCommand with 6 Parameters: 
cmd.Parameters["Id"] 
cmd.Parameters["Field1"] 
cmd.Parameters["Field2"] 
cmd.Parameters["Field3"] 
cmd.Parameters["Field4"] 
cmd.Parameters["Field5"] 

When I remove the parameter Id with: 
cmd.Parameters.RemoveAt("Id"); 

After that I want to get the value or the indexOf(..), of Parameter Field5 with this.GetParameter("Field5", dr["Field5"], ParameterDirection.Output). Then I will get an ArgumentOutOfRangeException. It worked perfectly with the 1.0.7 driver. 

Greetings, 
Paul

How to repeat:
Fill the parameters collection of the command with multiple values. Then remove one or more values at the beginning of the collection. After try to get the last Field on name with GetParameter("Fieldxx", dr["Fieldxx"], ParameterDirection.Output).
[19 Mar 2007 22:34] 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/22314
[26 Mar 2007 6:22] MC Brown
A note has been added to the 5.0.6 changelog.