Parameter count does not match Parameter Value count

24,048

Solution 1

Some SQL query or stored procedure has more parameters specified then parameters' values received.

Something like this:

command.CommandText = "EXEC test @a";
command.Parameters.Add("@a", "a");
command.Parameters.Add("@b", "b");

i.e. look at the database scheme. Was it changed? Were stored procedures changed?

Solution 2

I've found that if you are using parameters that have default values, certain libraries can't handle.

For instance, we have an application that uses an older version of Microsoft Enterprise Library Data Access method that allows you to pass parameters as an array.

It fails if the amount of items in the array doesn't match exactly the number of parameters on the stored procedure, regardless if some are 'optional' or not.

In cases like this have to use straight ADO.NET and use the cmd.Parameters.AddWithValues("@parameterName", value)

syntax for the required stored procedure parameters. You will not have to add, when using this method, command parameters for the 'optional' stored procedure parameters.

Solution 3

I had the same problem and I found that it was picking the fields from a temporary cache which was being maintained by MySQLHelper.

Share:
24,048
Matt
Author by

Matt

Updated on June 08, 2020

Comments

  • Matt
    Matt almost 4 years

    We're getting a server error saying "Parameter count does not match Parameter Value count." Anyone have any idea what this could mean?

    Our site's on ASP.NET Webforms running DotNetNuke as a CMS.

    I've tried uploading an older version of the web.config file but it doesn't seem to have changed since the error came up. It wasn't in any of our recent module file uploads because I reuploaded the old files from this morning that we changed.

    Could any changes in the database cause this or would it have to originate from an error in the code?

    Thanks.