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
- ....................................
- //delet post now
- [WebMethod]
- public static void DeletUSERpostnow(int id, string username)
- {
- string constr = ConfigurationManager.ConnectionStrings["DB"].ConnectionString;
- using (SqlConnection con = new SqlConnection(constr))
- {
- //DELETE USERPost , SHAREPOSTS FROM USERPost INNER JOIN SHAREPOSTS
- //WHERE USERPost.ID= SHAREPOSTS.ID and USERPost.UserName =@UserName
- using (SqlCommand cmd = new SqlCommand("GetDeletboth"))
- // ("DELETE USERPost, SHAREPOSTS FROM USERPost INNER JOIN SHAREPOSTS WHERE USERPost.ID= SHAREPOSTS.ShareId and USERPost.UserName =@UserName"))
- {
- 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
- }
- }
Sai SherlekarPosted Apr 6, 2018, 1:22 PM
If query is working properly then check your procedure get called or not?