0

我在编码

String Name = txtName.getText();
String Surname = txtSurname.getText();  
st.executeUpdate("DELETE from list WHERE Name=@Name and Surname=@Surname");

但它不会删除记录。语法有问题吗?请帮忙。

4

3 回答 3

2

您需要用实际值替换@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);
于 2012-05-07T09:31:11.493 回答
0

尝试:

st.executeNonQuery("DELETE from list WHERE Name=?e and Surname=?");

并将姓名和姓氏作为参数传递。

于 2012-05-07T09:31:13.317 回答
0

用这个

如果表列表存在。

这将起作用。

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()+"'");

谢谢你们

于 2012-05-07T09:32:47.617 回答