我的编辑存储过程有以下代码:
CREATE PROCEDURE [dbo].[sp_EditDates]
@ID int,
@PublishYear int,
@PublishMonth int,
@PayDte varchar(200),
@PublishDte varchar(200)
AS
BEGIN
-- Insert statements for procedure here
UPDATE PaymentAndPublishingDates SET PublishYear = @PublishYear, PublishMonth = @PublishMonth, PayDte = @PayDte, PublishDte = @PublishDte
WHERE ID=@ID;
END
以下是我的 Select 存储过程:
CREATE PROCEDURE [dbo].[sp_RetrieveAllDates]
AS BEGIN SELECT DISTINCT
PaymentAndPublishingDates.ID, PaymentAndPublishingDates.PublishYear,
PaymentAndPublishingDates.PublishMonth,
CONVERT(VARCHAR,PaymentAndPublishingDates.PayDte,106)AS PayDate,
CONVERT(VARCHAR,PaymentAndPublishingDates.PublishDte,120) AS PublishDate
FROM PaymentAndPublishingDates
END
我有一个这样的数据源:
<asp:ListView ID="ListView1" runat="server" DataSourceID="Payment_Dates"
InsertItemPosition="LastItem">
<AlternatingItemTemplate>
<tr style="background-color:#FFF8DC;">
<td>
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
</td>
<td>
<asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
</td>
<td>
<asp:Label ID="PublishYearLabel" runat="server"
Text='<%# Eval("PublishYear") %>' />
</td>
<td>
<asp:Label ID="PublishMonthLabel" runat="server"
Text='<%# Eval("PublishMonth") %>' />
</td>
<td>
<asp:Label ID="PayDateLabel" runat="server" Text='<%# Eval("PayDate") %>' />
</td>
<td>
<asp:Label ID="PublishDateLabel" runat="server"
Text='<%# Eval("PublishDate") %>' />
</td>
</tr>
</AlternatingItemTemplate>
<EditItemTemplate>
<tr style="background-color:#008A8C;color: #FFFFFF;">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update"
Text="Update" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Cancel" />
</td>
<td>
<asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("ID") %>' />
</td>
<td>
<asp:TextBox ID="PublishYearTextBox" runat="server"
Text='<%# Bind("PublishYear") %>' />
</td>
<td>
<asp:TextBox ID="PublishMonthTextBox" runat="server"
Text='<%# Bind("PublishMonth") %>' />
</td>
<td>
<asp:TextBox ID="PayDateTextBox" runat="server" Text='<%# Bind("PayDate") %>' />
</td>
<td>
<asp:TextBox ID="PublishDateTextBox" runat="server"
Text='<%# Bind("PublishDate") %>' />
</td>
</tr>
</EditItemTemplate>
<EmptyDataTemplate>
<table runat="server"
style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
<tr>
<td>
No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert"
Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Clear" />
</td>
<td>
</td>
<td>
<asp:TextBox ID="PublishYearTextBox" runat="server"
Text='<%# Bind("PublishYear") %>' />
</td>
<td>
<asp:TextBox ID="PublishMonthTextBox" runat="server"
Text='<%# Bind("PublishMonth") %>' />
</td>
<td>
<asp:TextBox ID="PayDateTextBox" runat="server" Text='<%# Bind("PayDate") %>' />
</td>
<td>
<asp:TextBox ID="PublishDateTextBox" runat="server"
Text='<%# Bind("PublishDate") %>' />
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr style="background-color:#DCDCDC;color: #000000;">
<td>
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
</td>
<td>
<asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
</td>
<td>
<asp:Label ID="PublishYearLabel" runat="server"
Text='<%# Eval("PublishYear") %>' />
</td>
<td>
<asp:Label ID="PublishMonthLabel" runat="server"
Text='<%# Eval("PublishMonth") %>' />
</td>
<td>
<asp:Label ID="PayDateLabel" runat="server" Text='<%# Eval("PayDate") %>' />
</td>
<td>
<asp:Label ID="PublishDateLabel" runat="server"
Text='<%# Eval("PublishDate") %>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="1"
style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
<tr runat="server" style="background-color:#DCDCDC;color: #000000;">
<th runat="server">
</th>
<th runat="server">
ID</th>
<th runat="server">
PublishYear</th>
<th runat="server">
PublishMonth</th>
<th runat="server">
PayDate</th>
<th runat="server">
PublishDate</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server"
style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;">
</td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<tr style="background-color:#008A8C;font-weight: bold;color: #FFFFFF;">
<td>
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
</td>
<td>
<asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
</td>
<td>
<asp:Label ID="PublishYearLabel" runat="server"
Text='<%# Eval("PublishYear") %>' />
</td>
<td>
<asp:Label ID="PublishMonthLabel" runat="server"
Text='<%# Eval("PublishMonth") %>' />
</td>
<td>
<asp:Label ID="PayDateLabel" runat="server" Text='<%# Eval("PayDate") %>' />
</td>
<td>
<asp:Label ID="PublishDateLabel" runat="server"
Text='<%# Eval("PublishDate") %>' />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="Payment_Dates" runat="server"
ConnectionString="<%$ ConnectionStrings:TUT_ElectronicPayslipsConnectionString %>"
InsertCommand="sp_CapturePayDate" InsertCommandType="StoredProcedure"
SelectCommand="sp_RetrieveAllDates" SelectCommandType="StoredProcedure"
UpdateCommand="sp_EditDates" UpdateCommandType="StoredProcedure">
<InsertParameters>
<asp:Parameter Name="PublishYear" Type="Int32" />
<asp:Parameter Name="PublishMonth" Type="Int32" />
<asp:Parameter Name="PayDte" Type="String" />
<asp:Parameter Name="PublishDte" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="PublishYear" Type="Int32" />
<asp:Parameter Name="PublishMonth" Type="Int32" />
<asp:Parameter Name="PayDte" Type="String" />
<asp:Parameter Name="PublishDte" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
数据显示正常,但是当我尝试编辑字段时出现此错误“过程或函数 sp_EditDates 指定了太多参数”。
请帮忙