This has to be the most annoying error that you can get, you have all your arguments lined up you know that the inputs for your stored procedure match the fileds from you gridview but still it errors.
Well finally I found out why I get this error, it's all to do with my typing or lack of it.
If I have my gridview populating from the a stored procedure which runs something like this:
Select
CREATE PROCEDURE SelectTable1
AS
SELECT field1, field2, field3, id
FROM table1
Update
1: CREATE PROCEDURE UpdateTable1
2: @field1 varchar(10) = null,
3: @feild2 varchar(10) = null,
4: @field3 varchar(10) = null,
5: @id int
6: AS
7: UPDATE table1
8: SET field1 = @field1, field2 = @feild2, field3 = @field3,
9: WHERE id = @id
Grid View
1: <asp:GridView ID="GridView1" runat="server" runat="server" AllowPaging="True" AllowSorting="True"
2: AutoGenerateColumns="False" DataKeyNames="ID"
3: DataSourceID="DataSource1" PageSize="20" AutoGenerateEditButton="True">
4: <Columns>
5: <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
6: <asp:BoundField DataField="field1" HeaderText="field1" SortExpression="field1" />
7: <asp:BoundField DataField="field2" HeaderText="field2" SortExpression="field2" />
8: <asp:BoundField DataField="field3" HeaderText="field3" SortExpression="field3" />
9: </Columns>
10: </asp:GridView>
Data Source
1: <asp:SqlDataSource ID="DataSource1" runat="server"ConnectionString="<%$ ConnectionStrings:strConnectionString %>"
2: SelectCommand="selectTable1" SelectCommandType="StoredProcedure" UpdateCommand="UpdateTable1" UpdateCommandType="StoredProcedure">
3: <SelectParameters>
4: </SelectParameters>
5: <UpdateParameters>
6: <asp:Parameter DefaultValue="0" Name="ID" Type="Int32" />
7: <asp:Parameter DefaultValue="" Name="field1" Type="String" />
8: <asp:Parameter DefaultValue="" Name="field2" Type="String" />
9: <asp:Parameter DefaultValue="" Name="field3" Type="String" />
10: </UpdateParameters>
11: </asp:SqlDataSource>
So if you were to create this code inclueding the tables and data connections and tried to run the update you would get the following error "Procedure or function UpdateTable1 has too many arguments specified", looking at the code it all lines up. The stored procedure orks fine on it's own the select works the right arguments are being passed over, so what is the problem?
Well the problem lies in this case with field2 or feild2 aas the variable in the stored procedure is that slight typo causes the error, so if you get the error to many arguments check that your variables amtch with your selected fieldnames.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5