我必须删除记录,但收到错误Specify the table containing the records you want to delete.
oleDbCmd.CommandText = "DELETE call_samp FROM call_samp INNER JOIN prod_mas ON prod_mas.id=call_samp.prod_id WHERE call_samp.id=@id;";
oleDbCmd.Parameters.AddWithValue("@id", 495);
oleDbCmd.ExecuteNonQuery();
尝试了
DELETE call_samp.*
FROM call_samp
INNER JOIN prod_mas ON prod_mas.id=call_samp.prod_id WHERE call_samp.id=495;
错误无法从特定行中删除。
答案 0 :(得分:0)
你可以试试这个。
oleDbCmd.CommandText = "DELETE call_samp FROM call_samp INNER JOIN prod_mas ON prod_mas.id=call_samp.prod_id WHERE call_samp.id=@id;";
oleDbCmd.Parameters.AddWithValue("@id", 495);
oleDbCmd.ExecuteNonQuery();
答案 1 :(得分:0)
这只是您的SQL代码的问题。使用delete命令时无需指定一列或多列,因为您要删除整行。
请继续:
DELETE FROM call_samp INNER JOIN prod_mas ON prod_mas.id=call_samp.prod_id WHERE call_samp.id=@id;
表示SQL代码。