sqldatasource update method

i cannot get my update to work within my gridview.
i get the following error.
Procedure or function sp_GCN_Update has too many arguments specified
<Columns>
                            <asp:TemplateField HeaderText="Update" ShowHeader="False">
                                <EditItemTemplate>
                                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                                        Text="Update"></asp:LinkButton>
                                    <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                                        Text="Cancel"></asp:LinkButton>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                                        Text="Edit"></asp:LinkButton>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="GCNID" HeaderText="GCNID" ReadOnly="True" SortExpression="GCNID" />
                            <asp:BoundField DataField="GCN" HeaderText="GCN" ReadOnly="True" SortExpression="GCN" />
                            <asp:TemplateField HeaderText="ExpectedVolume" SortExpression="ExpectedVolume">
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtExpectedVolume" runat="server" Text='<%# Bind("ExpectedVolume") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="lblExpectedVolume" runat="server" Text='<%# Bind("ExpectedVolume") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="Report" HeaderText="Report" ReadOnly="True" SortExpression="Report" />
                            <asp:BoundField DataField="BatchCode" HeaderText="BatchCode" ReadOnly="True" SortExpression="BatchCode" />
                            <asp:BoundField DataField="CSRep" HeaderText="CSRep" ReadOnly="True" SortExpression="CSRep" />
                        </Columns>
                    </asp:GridView>
                </td>
            </tr>
            <tr>
                <td colspan="10">
                    <asp:SqlDataSource ID="sql_dsGetGCN" runat="server" ConnectionString="<%$ ConnectionStrings:ReportsDataConnectionString %>"
                        SelectCommand="sp_GetGCNs" SelectCommandType="StoredProcedure"
                        UpdateCommand="sp_GCN_Update" UpdateCommandType="StoredProcedure">
                        
                        <SelectParameters>
                            <asp:ControlParameter ControlID="ddl_GCN" Name="GCN" PropertyName="SelectedValue"
                                Type="String" />
                        </SelectParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="ExpectedVolume" Type="Int32" />
                        </UpdateParameters>
                    </asp:SqlDataSource>

my sp
--CREATE PROCEDURE [dbo].[sp_GCN_Update]
ALTER PROCEDURE [dbo].[sp_GCN_Update]

	@ExpectedVolume int	

AS

BEGIN

UPDATE
	tblGCN
SET
	ExpectedVolume = @ExpectedVolume
WHERE
	ExpectedVolume = @ExpectedVolume
END

Open in new window

aneilgAsked:
Who is Participating?
 
aneilgAuthor Commented:
What should my sp be like.

my table is called tblGCN
and i want to update the expectedvolume field.
0
 
aneilgAuthor Commented:
                   <asp:SqlDataSource ID="sql_dsGetGCN" runat="server" ConnectionString="<%$ ConnectionStrings:ReportsDataConnectionString %>"
                        SelectCommand="sp_GetGCNs" SelectCommandType="StoredProcedure"
                        UpdateCommand="sp_GCN_Update" UpdateCommandType="StoredProcedure">
                       
                        <SelectParameters>
                            <asp:ControlParameter ControlID="ddl_GCN" Name="GCN" PropertyName="SelectedValue"
                                Type="String" />
                        </SelectParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="ExpectedVolume" Type="Int32" />
                        </UpdateParameters>
                    </asp:SqlDataSource>
0
 
SriVaddadiCommented:
Your update query does not seem right though.

UPDATE
      tblGCN
SET
      ExpectedVolume = @ExpectedVolume
WHERE
      ExpectedVolume = @ExpectedVolume

You are trying to update a record with the same value as existing? does not make sense
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.