posts - 31, comments - 88, trackbacks - 0

My Links

News

Archives

Post Categories

Friday, May 07, 2010

Procedure or function has too many arguments specified

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.

Posted On Friday, May 07, 2010 9:35 AM | Feedback (2) | Filed Under [ ASP.NET SQL ]

Powered by: