我有两个表要删除数据:用户表和反馈表。
以下是我的代码(不起作用):
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();
有没有办法在asp.net中使用1个SQL查询从两个表中删除SAME数据?