SQL Server Stored Procedure Update not working with ASP.Net C# GridView RowUpdating

后端 未结 3 448
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-26 02:04

I am having an issue but I am not getting any errors thrown. What\'s happening is that I have a stored procedure that is driving my update but I am unable to get the gridview to

3条回答
  •  抹茶落季
    2021-01-26 02:55

    You pass the Status=Update and this force your stored procedure to run the Update part of your SP, but then you call the SqlDataAdapter.Fill method that is supposed to SELECT records to fill the dataset, but your procedure executes an UPDATE e no records are returned.

    If you really want to execute this very non intuitive and (in my opinion) weak code, you need to move the select part at the end of the stored procedure and execute it in every case.

    IF(@Status = 'Add')
    BEGIN
       ....
    END
    ELSE IF(@Status = 'Update')
    BEGIN
       ....
    END
    ELSE IF(@Status = 'Delete')
    BEGIN
       ....
    END
    -- Always return the records after the update/insert/delete 
    SELECT * FROM WestCompetition 
    

    However the above comment of marc_s has said everything, nothing to add at that

提交回复
热议问题