views:

199

answers:

2

Hi,

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

http://www.oneworldunited.com

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,
Matt

+3  A: 

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

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?

abatishchev
Is there any way to tell which stored procedure it was?
Matt
@Matt: go to `DotNetNuke.Data.SqlDataProvider.GetPortals(string)` and find out which SP is being called there
abatishchev
Found it, turns out the stored proc GetPortals was changed some how... kinda scary for a live site. Thanks for the help!
Matt
@Matt: Glad it helped! :)
abatishchev
A: 

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.

Brian