2014-10-17 82 views
0

我一直在寻找了几个小时试图找出网络是什么原因造成这个异常,我觉得我失去了一些东西......'过程或函数指定的参数太多'?

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
<title></title> 
</head> 
<body> 
<form id="form1" runat="server"> 
<div> 

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
     BackColor="White" BorderColor="#999999" BorderStyle="None" 
     BorderWidth="1px" CellPadding="3" DataKeyNames="ProductID" 
DataSourceID="SqlDataSource1" 
GridLines="Vertical"> 
     <AlternatingRowStyle BackColor="#DCDCDC" /> 
     <Columns> 
      <asp:CommandField ShowEditButton="True" /> 
      <asp:BoundField DataField="ProductID" HeaderText="ProductID" 
InsertVisible="False" ReadOnly="True" SortExpression="ProductID" /> 
      <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" 
SortExpression="CategoryID" /> 
      <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" 
    /> 
      <asp:BoundField DataField="ShortDescription" HeaderText="ShortDescription" 
SortExpression="ShortDescription" /> 
      <asp:BoundField DataField="LongDescription" HeaderText="LongDescription" 
SortExpression="LongDescription" /> 
      <asp:BoundField DataField="ImageUrl" HeaderText="ImageUrl" 
SortExpression="ImageUrl" /> 
      <asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" 
/> 
     </Columns> 
     <FooterStyle BackColor="#CCCCCC" ForeColor="Black" /> 
     <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" /> 
     <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" /> 
     <RowStyle BackColor="#EEEEEE" ForeColor="Black" /> 
     <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" /> 
     <SortedAscendingCellStyle BackColor="#F1F1F1" /> 
     <SortedAscendingHeaderStyle BackColor="#0000A9" /> 
     <SortedDescendingCellStyle BackColor="#CAC9C9" /> 
     <SortedDescendingHeaderStyle BackColor="#000065" /> 
    </asp:GridView> 
    <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2" 
DataTextField="Title" DataValueField="CategoryID"> 
    </asp:DropDownList> 
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
     ConnectionString="<%$ ConnectionStrings:s3435926ConnectionString %>" 
     SelectCommand="SELECT [CategoryID], [Title] FROM [Category]"> 
</asp:SqlDataSource> 
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ 
ConnectionStrings:s3435926ConnectionString %>" 
     SelectCommand="SelectProductsWithParam" SelectCommandType="StoredProcedure" 
     UpdateCommand="UpdateProdsWithParam" UpdateCommandType="StoredProcedure"> 
     <SelectParameters> 
      <asp:FormParameter FormField="DropDownList1" Name="prodID" Type="Int32" /> 
     </SelectParameters> 
     <UpdateParameters> 
      <asp:Parameter Name="prodID" Type="Int32" /> 
      <asp:Parameter Name="CatID" Type="Int32" /> 
      <asp:Parameter Name="title" Type="String" /> 
      <asp:Parameter Name="Sdesc" Type="String" /> 
      <asp:Parameter Name="Ldesc" Type="String" /> 
      <asp:Parameter Name="url" Type="String" /> 
      <asp:Parameter Name="price" Type="Decimal" /> 
     </UpdateParameters> 
    </asp:SqlDataSource> 

    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> 

</div> 
</form> 
</body> 
</html> 

的SP是

[dbo].[UpdateProdsWithParam] @prodID int, @CatID int, @title nvarchar(50), 
              @Sdesc nvarchar(100), @Ldesc nvarchar(200), 
              @url nvarchar(50), @price money 
AS 
UPDATE Product 
SET CategoryID = @CatID, Title = @title, 
ShortDescription = @Sdesc, LongDescription = @Ldesc, 
ImageUrl = @url, Price = @price 
WHERE ProductID = @prodID 

我得到'过程或函数指定的参数太多'

有什么建议吗?

+0

我认为这是更新,是吗?你可以打开SQL Profiler并查看哪些SQL正在发送到UpdateProdsWithParam? – sh1rts 2014-10-17 01:06:32

回答

0

分享您的C#代码。错误清楚地表明您传递的参数太多。查看你的参数计数&参数名称。

相关问题