Procedure or function has too many arguments specified

Posted by bullpit on Geeks with Blogs See other posts from Geeks with Blogs or by bullpit
Published on Fri, 07 May 2010 14:35:50 GMT Indexed on 2010/05/11 2:55 UTC
Read the original article Hit count: 294

Filed under:

This error took me a while to figure out. I was using SqlDataSource with stored procedures for SELECT and UPDATE commands. The SELECT worked fine. Then I added UPDATE command and while trying to update, I would get this error:

"Procedure of function has too many arguments specified"

Apparently, good guys at .NET decided it is necessary to send SELECT parameters with the UPDATE command as well. So when I was sending the required parameters to the UPDATE sp, in reality, it was also getting my SELECT parameters, and thus failing.

I had to add the extra parameters in the UPDATE stored procedure and make them NULLABLE so that they are not required....phew...

Here is piece of SP with unused parameters.

ALTER PROCEDURE [dbo].[UpdateMaintenanceRecord]
       @RecordID INT
    ,@District VARCHAR(255)
    ,@Location VARCHAR(255)
   
    --UNUSED PARAMETERS
    ,@MTBillTo VARCHAR(255) = NULL
    ,@SerialNumber VARCHAR(255) = NULL
    ,@PartNumber VARCHAR(255) = NULL

Update: I was getting that error because unkowingly, I had bound the extra fields in my GridVeiw with Bind() call. I changed all the extra one's, which did not need to be in Update, to Eval() and everything works fine.

© Geeks with Blogs or respective owner