I have 2 tables that I want to delete data from: User table and feedback table.
Here are my codes (which doesn't work):
string strConnectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
SqlConnection myConnect = new SqlConnection(strConnectionString);
string strtext = "DELETE FROM [User] WHERE Username = @user";
strtext += "DELETE FROM Feedback WHERE Username = @user";
strtext += "DELETE FROM Light WHERE Username = @user";
strtext += "DELETE FROM Temperature WHERE Username = @user";
strtext += "DELETE FROM Airquality WHERE Username = @user";
strtext += "DELETE FROM Bodycondition WHERE Username = @user";
SqlCommand cmd = new SqlCommand(strtext, myConnect);
cmd.Parameters.Add("@user", SqlDbType.VarChar);
cmd.Parameters["@user"].Value = txtdeleteuser.Text;
myConnect.Open();
int result = cmd.ExecuteNonQuery();
Is there any way to delete the SAME data from both tables using 1 SQL query in asp.net?