Gridview - how to use stored procedures to update

Discussion in 'ASP .Net Datagrid Control' started by Roberto Kohler, Dec 12, 2005.

  1. I am trying to use a stored procedure to update a row in a Gridview but I
    get the error
    "Procedure or function sc_updDEPT has too many arguments specified"

    The Stored procedure takes 3 parameters "sc_updDEPT @idplant, @iddept,
    @deptname"

    I configured the SqlDataSource to use the sc_updDEPT StoredProcedure for
    updates:

    UpdateCommand="sc_updDEPT"
    UpdateCommandType="StoredProcedure"
    ConflictDetection="CompareAllValues"

    <UpdateParameters>
    <asp:parameter Name="idplant" Type="Int32" />
    <asp:parameter Name="iddept" Type="String" />
    <asp:parameter Name="deptname" Type="String" />
    </UpdateParameters>

    The Primary Key in the table is "idplant, iddept"
    In the Gridview I set
    DataKeyNames="idplant, iddept"

    When I try to do the update I get the error
    Exception Details: System.Data.SqlClient.SqlException:
    Procedure or function sc_updDEPT has too many arguments specified.

    Any help would be appreciated
     
    Roberto Kohler, Dec 12, 2005
    #1
    1. Advertising

  2. Roberto Kohler

    LehrSJ Guest

    I had that problem. I had some template fields where I was using a label on
    the edit template to display data. I had checked "two-way" databinding.
    This caused the template field to be sent to the procedure. i just needed to
    uncheck the two-way databinding.
    --
    LehrSJ


    "Roberto Kohler" wrote:

    > I am trying to use a stored procedure to update a row in a Gridview but I
    > get the error
    > "Procedure or function sc_updDEPT has too many arguments specified"
    >
    > The Stored procedure takes 3 parameters "sc_updDEPT @idplant, @iddept,
    > @deptname"
    >
    > I configured the SqlDataSource to use the sc_updDEPT StoredProcedure for
    > updates:
    >
    > UpdateCommand="sc_updDEPT"
    > UpdateCommandType="StoredProcedure"
    > ConflictDetection="CompareAllValues"
    >
    > <UpdateParameters>
    > <asp:parameter Name="idplant" Type="Int32" />
    > <asp:parameter Name="iddept" Type="String" />
    > <asp:parameter Name="deptname" Type="String" />
    > </UpdateParameters>
    >
    > The Primary Key in the table is "idplant, iddept"
    > In the Gridview I set
    > DataKeyNames="idplant, iddept"
    >
    > When I try to do the update I get the error
    > Exception Details: System.Data.SqlClient.SqlException:
    > Procedure or function sc_updDEPT has too many arguments specified.
    >
    > Any help would be appreciated
    >
    >
    >
     
    LehrSJ, Jan 1, 2006
    #2
    1. Advertising

  3. Roberto Kohler

    Guest

    Roberto, I am having exactly the same problem as you.

    Have you solved this yet?

    Thanks, regards from dnw.
     
    , Jan 2, 2006
    #3
  4. I got it to work by naming the parĂ¡meters in the stored procedures,
    just like the table's column names they refer to with an "@" prepended.

    They used to be:
    procedure sc_updDEPTOS (
    @idplanta INT,
    @iddepto VARCHAR(16),
    @nomdepto VARCHAR(40)
    )
    and it didn't work.

    It worked when I changed it to

    procedure sc_updDEPTOS (
    @dp_idplanta INT,
    @dp_iddepto VARCHAR(16),
    @dp_nomdepto VARCHAR(40)
    )

    The updateParameters in the SQLDataSource are defined as:

    <UpdateParameters>
    <asp:parameter Name="dp_idplanta" Type="Int32" />
    <asp:parameter Name="dp_iddepto" Type="String" />
    <asp:parameter Name="dp_nomdepto" Type="String" />
    </UpdateParameters>
     
    Roberto Kohler, Jan 11, 2006
    #4
  5. Roberto Kohler

    Guest

    Thanks a lot.
    -dnw.
     
    , Jan 13, 2006
    #5
  6. Hi Roberto,
    I had try this solutions but it not working.its showing
    same error.Give me some solutions.



    *** Sent via Developersdex http://www.developersdex.com ***
     
    Meeran Mohideen, Mar 20, 2006
    #6
  7. Roberto Kohler

    pavan kumar Guest

    pavan kumar, Dec 7, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Taras
    Replies:
    2
    Views:
    4,813
    Rick Spiewak
    Oct 5, 2003
  2. Soumitra Banerjee

    Putting stored procedures in a dll

    Soumitra Banerjee, Feb 27, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    407
    Soumitra Banerjee
    Feb 27, 2004
  3. Joel  Thornton

    GridView paging/sorting - will it work with stored procedures?

    Joel Thornton, Feb 17, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    189
    Joel Thornton
    Feb 17, 2005
  4. mc
    Replies:
    0
    Views:
    736
  5. Joel  Thornton

    GridView paging/sorting - will it work with stored procedures?

    Joel Thornton, Feb 17, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    369
    Joel Thornton
    Feb 17, 2005
Loading...

Share This Page