This is a migrated thread and some comments may be shown as answers.

Procedure or function has too many arguments specified error

10 Answers 1477 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Reda
Top achievements
Rank 1
Reda asked on 19 Sep 2008, 06:18 PM

Hello everyone:

I have been goin crazy over the last 3hrs trying to resolve this problem, can someone please help me....i keep getting this error: "Procedure or function spUpdatePerm has too many arguments specified"

I haved searched all the forums and support, i also tried everything i can but still get the same error.

Here is the aspx code:

<

telerik:RadGrid ID="gridPerms" runat="server" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" DataSourceID="dsPerms" GridLines="None" ShowGroupPanel="True" Skin="Office2007" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" ShowStatusBar="true">

 <AlternatingItemStyle BackColor="#E6E6E6" Font-Bold="False" Font-Italic="False"
Font-Overline="False" Font-Strikeout="False" Font-Underline="False"
Wrap="True" />

 <PagerStyle Mode="NextPrevAndNumeric" />

<MasterTableView CommandItemDisplay="Top" AutoGenerateColumns="False" DataKeyNames="PermissionID" DataSourceID="dsPerms">

<RowIndicatorColumn>
    
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>

<
ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>

<
Columns> 
    
<telerik:GridEditCommandColumn></telerik:GridEditCommandColumn>
    <telerik:GridBoundColumn DataField="PermissionID" DataType="System.Int16" HeaderText="Permission ID" ReadOnly="True" SortExpression="PermissionID" UniqueName="PermissionID">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="PermissionName" HeaderText="Permission Name" SortExpression="PermissionName" UniqueName="PermissionName" DataType="System.String">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="PermissionLevel" DataType="System.Int16" HeaderText="Permission Level" SortExpression="PermissionLevel" UniqueName="PermissionLevel">
    </telerik:GridBoundColumn>
</Columns>

<EditFormSettings>
    
<EditColumn UniqueName="EditCommandColumn"></EditColumn>
</EditFormSettings>

</MasterTableView>

<ClientSettings AllowDragToGroup="True"></ClientSettings>
<FilterMenu EnableTheming="True" Skin="Office2007">
    <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
</FilterMenu>

</telerik:RadGrid>

 <asp:SqlDataSource ID="dsPerms" runat="server" ConnectionString="<%$ ConnectionStrings:VentrolSecurityConnectionString %>" InsertCommand="spCreatePerm" InsertCommandType="StoredProcedure" SelectCommand="spGetPerms" SelectCommandType="StoredProcedure"     
UpdateCommand
="spUpdatePerm" UpdateCommandType="StoredProcedure">
<UpdateParameters>
    <asp:Parameter Direction="Input" Name="argPermissionID" Type="Int16" />
    <asp:Parameter Direction="Input" Name="argPermissionLevel" Type="Int16" />
    <asp:Parameter Direction="Input" Name="argPermissionName" Type="String" ConvertEmptyStringToNull="true" />
</UpdateParameters>
<InsertParameters>
    <asp:Parameter Direction="Input" Name="argPermissionLevel" Type="Int16" />
    <asp:Parameter Direction="Input" Name="argPermissionName" Type="String" ConvertEmptyStringToNull="true" />
</InsertParameters>
</asp:SqlDataSource>


Here is the stored procedure to insert:


ALTER
PROCEDURE [dbo].[spCreatePerm]
-- Add the parameters for the stored procedure here
@argPermissionLevel int,
@argPermissionName nvarchar(50)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
INSERT tbl_secure_Permission(PermissionLevel,PermissionName)
VALUES(@argPermissionLevel,@argPermissionName)
END

Here is the stored procedure to update:

ALTER
PROCEDURE [dbo].[spUpdatePerm]
-- Add the parameters for the stored procedure here
@argPermissionID int,
@argPermissionLevel int,
@argPermissionName nvarchar(50)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
UPDATE tbl_secure_Permission
SET PermissionLevel = @argPermissionLevel,
        
PermissionName = @argPermissionName
WHERE PermissionID = @argPermissionID
END

Please if anyone can help, much appreciation.

Thanks in advance.... 

10 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 22 Sep 2008, 07:02 AM
Hello Reda,

You can use SqlDataSource Updating event to check using the debugger how many parameters are passed.

Kind regards,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Reda
Top achievements
Rank 1
answered on 22 Sep 2008, 03:21 PM
Thanks for your reply Vlad,

I did what you suggested and it tells me the count of parameters is 6, which is wrong. I ran the stored procedure within sql studio management and it works just fine. The first 3 parameters being passed are correct "@argPermissionID","@argPermissionLevel","@argPermissionName"
which is what the stored procedure accepts but with wrong values all are empty. Then for some reason 3 other parameters are passed along with it "@PermissionID","@PermissionLevel","@PermissionName" that have the correct values but not the right names.

I am not sure what to do next, any suggestions will be greatly appreciated.

Thanks in advance.

Reda
0
Iana Tsolova
Telerik team
answered on 25 Sep 2008, 09:38 AM
Hi Reda,

Please try setting your parameter names so that they are equal to the data field names and check if the problem persists:
<UpdateParameters> 
    <asp:Parameter Direction="Input" Name="PermissionID" Type="Int16" /> 
    <asp:Parameter Direction="Input" Name="PermissionLevel" Type="Int16" /> 
    <asp:Parameter Direction="Input" Name="PermissionName" Type="String" ConvertEmptyStringToNull="true" /> 
</UpdateParameters> 
 

When automatic operations are enabled for grid editing, the grid passes the new values to the SqlDataSource in parameters with the same names as the DataField of each column.
Find more about RadGrid automatic operations in the following resources:
http://demos.telerik.com/ASPNET/Prometheus/Grid/Examples/DataEditing/AllEditableColumns/DefaultCS.aspx
http://www.telerik.com/help/radcontrols/prometheus/?grdAutomaticDataSourceOperations.html
http://www.telerik.com/community/code-library/submission/b311D-kkmhe.aspx

Let us know if this helps.

Best wishes,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Reda
Top achievements
Rank 1
answered on 25 Sep 2008, 02:13 PM
Thanks for the reply,

I tried what you told me and now it gives me this error:

Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: Procedure or function 'spUpdatePerm' expects parameter '@argPermissionID', which was not supplied.'

I read all the resources and I am doing the same thing just mine is not working.
Not sure what to do again.

Thanks in advance for your help.
0
Accepted
Iana Tsolova
Telerik team
answered on 25 Sep 2008, 02:34 PM
Hello Reda,

Can you try changing the parameters names in your stored procedure as well?
 
ALTER PROCEDURE [dbo].[spUpdatePerm]   
-- Add the parameters for the stored procedure here  
@PermissionID int,  
@PermissionLevel int,  
@PermissionName nvarchar(50)  
AS 
BEGIN 
-- SET NOCOUNT ON added to prevent extra result sets from  
-- interfering with SELECT statements.  
SET NOCOUNT ON;   
-- Insert statements for procedure here  
UPDATE tbl_secure_Permission  
SET PermissionLevel = @PermissionLevel,  
        PermissionName = @PermissionName  
WHERE PermissionID = @PermissionID  
END 

Let me know if this works for you.

Best wishes,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Reda
Top achievements
Rank 1
answered on 25 Sep 2008, 02:56 PM
It worked Iana, thank you soo much. I really appreciate your help. Great products and great support.

Thank you very much, have a nice day.

Reda  
0
Behtash Moradi
Top achievements
Rank 1
answered on 10 Jan 2010, 02:14 PM
I had same problem and i fixed it after one day googling.
if you change Bind("FeildName") intp Eval("FeildName"), it will work.


BEHTASH MORADI
senior C# developer

0
Todd
Top achievements
Rank 1
answered on 05 Mar 2011, 10:27 PM
If you have defined fewer parameters in your UpdateParameters collection than what is being passed to your SQL or Stored Procedure, then you will get this error.  To fix this issue, remove the unneeded parameter in the SqlDataSource_Updating event like so:

protected void SqlDataSource1_Updating(object sender, SqlDataSourceCommandEventArgs e)
{
     // Remove unneeded parameter
     e.Command.Parameters.Remove(e.Command.Parameters["@Param1"]);
}

In my case, I needed this extra parameter when Inserting but not updating so I had to remove it in the Updating event..
0
Daniel
Top achievements
Rank 1
answered on 13 May 2011, 07:04 PM
Thanks Todd!  That last bit was super helpful for me!

-= Daniel
0
Amparo
Top achievements
Rank 1
answered on 24 Apr 2015, 03:39 PM

Thank you Todd!

That fixed my issue with this error as well!

Tags
Grid
Asked by
Reda
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Reda
Top achievements
Rank 1
Iana Tsolova
Telerik team
Behtash Moradi
Top achievements
Rank 1
Todd
Top achievements
Rank 1
Daniel
Top achievements
Rank 1
Amparo
Top achievements
Rank 1
Share this question
or