Ramco Ramco

Ramco Ramco

  • 442
  • 3.4k
  • 515.4k

Record not getting deleted

Jun 2 2021 5:45 AM
Hi
Below is the code. Secondly i in ExecuteNonQuery returns -1.
if @Action='D'
Begin
--Update Location set IsActive = 'N' where Id = @Id;
Delete from Location where Id = @Id;
End
*********************
in **Id** it shows value as CHD\n
public int Delete(string Id)
{
int i;
using (SqlConnection con = new SqlConnection(cs))
{
con.Open();
SqlCommand com = new SqlCommand("sp_Location", con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.AddWithValue("@Id", Id);
com.Parameters.AddWithValue("@Action", "D");
i = com.ExecuteNonQuery();
}
return i;
}
**********************
In LocId it shows Chd
function Delete() {
var LocId = $("#hiddenId").val();
alert(LocId);
$.ajax({
url: "/Location/Delete",
data: { Id: LocId },
type: "POST",
dataType: "json",
success: function (result) {
$("#row_" + LocId).remove();
$('#DeleteModal').modal('hide');
clearTextBox();
$.notify(result.message, {
globalposition: "top center",
className: "success"
})
},
error: function (errormessage) {
alert(errormessage.responseText);
}
});
|

Answers (4)