Search code examples
sqlasp.nettelerik

Procedure has no parameters and arguments were supplied (literally no parameters)


I've been getting errors with this stored procedure so I tried simplifying it right down. For some reason I'm still getting an error saying the SP is expecting a parameter when I'm not using any parameters at all.

I should note that I'm trying to get this working via a Telerik RadDataform in ASP. Could it be that Telerik is adding a sneaky parameter here?

Here's the SP:

ALTER procedure [dbo].[NewEmployee_Update]                     
as
insert
    NewEmployeeDetails
select top 1
    NE.FormHeaderID,
    NE.VersionNumber + 1,
    getdate(),              -- AddDate
    'vibribbon',
    'Bart',
    'Simpson',
    'El Barto',
    'Rascal'
from
    OnlineFormHeader H
    inner join NewEmployeeDetails NE on NE.FormHeaderID = H.RecID
where
    H.RecID = 3
order by
    NE.VersionNumber desc

And the ASP DataSource:

<asp:SqlDataSource ID="dsEmployeeDetails" runat="server" ConnectionString="<%$ ConnectionStrings:OnlineStaffFormsConnectionString %>" InsertCommand="NewEmployee_Insert"
  InsertCommandType="StoredProcedure" UpdateCommand="NewEmployee_Update" UpdateCommandType="StoredProcedure" SelectCommand="select top 1
    NE.*
from
    OnlineFormHeader H
    inner join NewEmployeeDetails NE on NE.FormHeaderID = H.RecID
where
    H.RecID = @formHeaderID
order by
    NE.VersionNumber desc">
            <SelectParameters>
                <asp:QueryStringParameter Name="formHeaderID" QueryStringField="ID" Type="Int32" />
            </SelectParameters>
            <InsertParameters>
                <asp:SessionParameter Name="currentUser" SessionField="currentUser" />
                <asp:Parameter Name="FirstName" Type="String" />
                <asp:Parameter Name="LastName" Type="String" />
                <asp:Parameter Name="PreferredName" Type="String" />
                <asp:Parameter Name="JobTitle" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
    </div>
</asp:Content>

Solution

  • It seems the Telerik DataForm automatically adds the unique id of the record to be updated to the parameter set.

    Probably more noticeable here because I'm fudging the "update" command to insert instead.