please can you help me fix this multiple delete procedure query, nothing is been deleted on execution
when i click the delete button on modal to delete records from two tables, the jquery is executed but nothing is been deleted from the two tables. Here is the full code
- <script type="text/javascript">
-
- $(function () {
- $('[id*=btndelet55]').on('click', function () {
- var id = $(this).closest('tr').find($('[id*=ProdID]')).text();
- $('[id*=delet-modalNOW]').modal('show');
- $.ajax({
- type: "POST",
- url: "/HomePage.aspx/GetUSERPostDelet",
- data: '{id:"' + id + '"}',
- contentType: "application/json; charset=utf-8",
- dataType: "json",
- success: function (response) {
-
- $(".id").html('');
- $(".imageuser8").attr('src', '');
- $(".username").html('');
- $(".name").html('');
- $(".senddate5").html('');
- $(".contentpost").html('');
- $(".sharecontent").html('');
-
-
- $(".imagename15").html('');
- $(".path").html('');
-
-
- if (response.d.length > 0) {
- $(".id").html(response.d[0].Id);
- $(".imageuser8").attr('src', '/PROFILEPHOTOS/' + response.d[0].Imageuser7);
- $(".username").html(response.d[0].UserName);
- $(".name").html(response.d[0].Name);
- $(".senddate5").html(response.d[0].SendDate);
- $(".contentpost").html(response.d[0].ContentPost);
- $(".sharecontent").html(response.d[0].ShareContent);
- $(".imagename15").html(response.d[0].imagename15);
- $(".path").html(response.d[0].path);
- }
- },
-
- });
- return false;
- });
- $('[id*=buttondelete]').click(function () {
-
- var id = $('.id').html().trim();
- var name = $('.name').html().trim();
- var username = $('.username').html().trim();
- var contentPost = $('.contentpost').html().trim();
- var sharecontent = $('.sharecontent').html().trim();
- var senddate5 = $('.senddate5').html().trim();
- var imagename15 = $('.imagename15').html().trim();
- var path = $('.path').html().trim();
-
- var imageuser8 = $('.imageuser8').attr('src').slice(($('.imageuser8').attr('src').lastIndexOf('/') + 1), $('.imageuser8').attr('src').length);
-
-
-
- var dataObj = {
- id: id,
- name: name,
- username: username,
- contentpost: contentPost,
- sharecontent: sharecontent,
-
- senddate5: senddate5,
- imagename15: imagename15,
- path: path,
- imageuser8: imageuser8
- };
- $.ajax({
- type: "POST",
- url: "/HomePage.aspx/DeletUSERpostnow",
- data: JSON.stringify(dataObj),
-
- contentType: "application/json; charset=utf-8",
- dataType: "json",
- success: function (response) {
- $('#delet-modalNOW').modal('hide');
- $("#lblText").html('Post Deleted Successfully.');
- $('#dialog1').fadeIn('slow').delay(1000).fadeOut('slow');
- window.location.reload();
-
- $(".id").html('');
- $(".imageuser8").attr('src', '');
- $(".username").html('');
- $(".name").html('');
- $(".senddate5").html('');
- $(".contentpost").html('');
- $(".sharecontent").html('');
- $(".imagename15").html('');
- $(".path").html('');
- },
- failure: function (response) {
- alert(response.d);
- },
- error: function (response) {
- alert(response.d);
- }
- });
- return false;
- });
- });
- </script>
- ....................................
-
-
-
- [WebMethod]
- public static void DeletUSERpostnow(int id, string username)
- {
- string constr = ConfigurationManager.ConnectionStrings["DB"].ConnectionString;
- using (SqlConnection con = new SqlConnection(constr))
- {
-
-
- using (SqlCommand cmd = new SqlCommand("GetDeletboth"))
-
-
- {
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Parameters.AddWithValue("@UserName", HttpContext.Current.Session["userName"].ToString());
- cmd.Parameters.AddWithValue("@ID", id);
- cmd.Connection = con;
-
- con.Open();
- cmd.ExecuteNonQuery();
- con.Close();
-
- }
-
-
- procedure
-
- BEGIN
-
- DELETE up2 FROM SHAREPOSTS up2 INNER JOIN USERPost up1 ON up1.Id = up2.ShareId WHERE up1.Id =@ID AND up1.UserName=@UserName
-
- }
-
- }