我在编码
String Name = txtName.getText();
String Surname = txtSurname.getText();
st.executeUpdate("DELETE from list WHERE Name=@Name and Surname=@Surname");
但它不会删除记录。语法有问题吗?请帮忙。
您需要用实际值替换@name
和。@surname
并添加'
您的价值观:
DELETE from list WHERE Name='@Name' and Surname='@Surname'
String Name = txtName.getText().Trim();
String Surname = txtSurname.getText().Trim();
String query = "DELETE from list WHERE Name='" + Name + "' and Surname='" + Surname + "'";
st.executeUpdate(query);
尝试:
st.executeNonQuery("DELETE from list WHERE Name=?e and Surname=?");
并将姓名和姓氏作为参数传递。
用这个
如果表列表存在。
这将起作用。
String Name = txtName.getText();
String Surname = txtSurname.getText();
st.executeUpdate("DELETE from list WHERE Name='"+Name"' and Surname='"+Surname"'");
我这样修复它:
st.executeUpdate("DELETE from list WHERE Name='"+txtName.getText()+"'" + "and Surname='" + txtSurname.getText()+"'");
谢谢你们