Hi
I have below code but data is not getting updated.Neither i am getting any error message
try { using (SqlConnection con = new SqlConnection(Common.CommonFunction.cnn_Live)) { SqlCommand cmd = new SqlCommand("Sp_Department", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@EntryNo", SqlDbType.Int).Value = hdfDeleteID.Value; cmd.Parameters.Add("@Action", SqlDbType.NVarChar).Value = "D"; con.Open(); cmd.ExecuteNonQuery(); string message = Common.CommonFunction.recordDeletedSucessfully; ShowMessage("Success", "Record Saved Successfully", "Success"); GetData(); } } catch (Exception ex) { ShowMessage("Oops...", ex.Message, "error"); }
Stored Procedure
PROCEDURE [dbo].[sp_Department] @Action VARCHAR(1) ,@EntryNo int = Null ,@Description VARCHAR(50) = NULL ,@ShortName VARCHAR(25) = NULL AS BEGIN SET NOCOUNT ON; --UPDATE IF @Action = 'U' BEGIN UPDATE dbo.Department SET Description = @Description, updatedon = GETDATE() WHERE docentry = @EntryNo END --DELETE IF @Action = 'D' BEGIN UPDATE dbo.Department SET status = 0 , updatedon = GETDATE() WHERE docentry = @EntryNo END END
Thanks