消息:
Procedure or function Delete_Special has too many arguments specified.
我的sql脚本:
CREATE PROCEDURE [Delete_Special] @ThisID INT AS DELETE FROM [Daily_Specials] WHERE @ThisID = [ID] GO
调用存储过程的事件:
Protected Sub BTN_DeleteEvt_Click(sender As Object,e As EventArgs) sql_Specials.Delete() End Sub
删节标记:
<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>
解决方法
在答案中:
So,I’m thrashing around with the stored proc since it looks like the error is originating from there. One interesting thing that I notice is that the stored proc runs just fine from sql Query Analyzer and returns the autogenerated row number like it’s supposed to. However,when run from within Visual Studio,I get the same @Identity error and the stored proc neither adds a table row nor returns a row number.
I borrow a copy of Professional sql Server 2000 Programming by Robert Vieira. Good ‘ol Roberto has the following to say on page 367:
“You must use the OUTPUT keyword when you call the sproc,much as you did when you declared the sproc. This gives sql Server advance warning about the special handling that parameter will require. Be aware,however,that forgetting to include the OUTPUT keyword won’t create a runtime error,but the value for the output parameter won’t be moved into your variable (you’ll just wind up with what was already there – most likely a NULL value). …”
Since this sounded a lot like the @Identity error I was getting,I took a closer look at the @Identity deFinition in the stored proc on the assumption that something is failing to let sql Server kNow in advance that the stored proc has an OUTPUT return value. The variable initialization dialog Box that pops up when you run the stored proc has a dropdown Box for initializing the value of @Identity which seems wierd because it’s an OUTPUT variable. The two options are
<DEFAULT>
(the default setting in the dropdown) and<NULL>
.More as a result of being out of ideas than any rational thought process,I change
<DEFAULT>
to<NULL>
in the dialog Box and run the stored proc.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。