MySQL/ASP.NET Parameter ‘foo’ not found in the collection.

The Error

Parameter ‘foobar’ not found in the collection. at MySql.Data.MySqlClient.MySqlParameterCollection.GetParameterFlexible

Does not mean what it says. It’s somehow related to a documented bug, and fortunately does have a fix. It can occur when arguments in ASP.NET to a MySQL stored procedure are specified in a differing order.

The Solution

In ASP.NET when working with MySQL stored procedures, you MUST specify the parameters in the exact same order and upper/lower casing they appear in your stored procedure.

If this doesn’t fix it, you may have a problem with MySQL Stored Procedure Caching (how to fix). Symptoms here are that MySQL complains about wanting/missing parameters that you just deleted/added/updated being missing or too many.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s