I created a database with simple stored procedures to delete, insert, select, and update records in a database of three tables. All of them work, except for my delete instructions. When I try, I get the message Procedure or function has too many arguments . I tried to delete one parameter that he had, and ended up deleting all the records in the table, not the one that I targeted. What am I doing wrong? I have a feeling that there is an error in my SQL script, but I do not know what I can do differently to make it work.
Message:
The procedure or function Delete_Special contains too many arguments.
My SQL script:
CREATE PROCEDURE [Delete_Special] @ThisID INT AS DELETE FROM [Daily_Specials] WHERE @ThisID = [ID] GO
Event that invokes the stored procedure:
Protected Sub BTN_DeleteEvt_Click(sender As Object, e As EventArgs) SQL_Specials.Delete() End Sub
Abbreviated markup:
<asp:SqlDataSource ID="SQL_Specials" runat="server" DeleteCommand="Delete_Special" DeleteCommandType="StoredProcedure"> <DeleteParameters> <asp:ControlParameter ControlID="GV_Eagles_Specials" Name="ThisID" PropertyName="SelectedIndex" Type="Int32" /> </DeleteParameters> </asp:SqlDataSource> <asp:GridView ID="GV_Eagles_Specials" runat="server" DataSourceID="SQL_Specials" AutoGenerateColumns="False"> <Columns> <asp:TemplateField> <ItemTemplate> <asp:Button ID="BTN_EditSpecial" runat="server" CssClass="BigText" Text="Edit" OnClick="BTN_EditEvent_Click" /> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" HtmlEncode="False" DataFormatString="{0:MM/dd/yyyy}" /> <asp:BoundField DataField="Special" HeaderText="Special" SortExpression="Special" HtmlEncode="False" /> <asp:BoundField DataField="Side" HeaderText="Side" SortExpression="Side" HtmlEncode="False" /> <asp:BoundField DataField="Special_Price" HeaderText="Special Price" SortExpression="Special_Price" HtmlEncode="False" /> <asp:BoundField DataField="Soup" HeaderText="Soup" SortExpression="Soup" HtmlEncode="False" /> <asp:BoundField DataField="Soup_Price" HeaderText="Soup Price" SortExpression="Soup_Price" HtmlEncode="False" /> <asp:TemplateField ShowHeader="False"> <ItemTemplate> <asp:Button ID="BTN_DeleteEvt" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" CssClass="BigText" OnClick="BTN_DeleteEvt_Click" /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
source share