[英]deleting a record which selected by user?
I am coding 我正在编码
String Name = txtName.getText();
String Surname = txtSurname.getText();
st.executeUpdate("DELETE from list WHERE Name=@Name and Surname=@Surname");
but it doesn't delete the records. 但它不会删除记录。 Any problem with the syntax? 语法有问题吗? Please help. 请帮忙。
You need to replace @name
and @surname
with the actual values. 您需要将@name
和@surname
替换为实际值。
and add '
around your values: 并添加'
围绕你的价值观:
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);
try: 尝试:
st.executeNonQuery("DELETE from list WHERE Name=?e and Surname=?");
and pass the name and surname as parameters. 并将名称和姓氏作为参数传递。
Use this 用这个
If the table list exists . 如果表列表存在。
This will work . 这会奏效。
String Name = txtName.getText();
String Surname = txtSurname.getText();
st.executeUpdate("DELETE from list WHERE Name='"+Name"' and Surname='"+Surname"'");
I fixed it like that: 我这样解决了:
st.executeUpdate("DELETE from list WHERE Name='"+txtName.getText()+"'" + "and Surname='" + txtSurname.getText()+"'");
Thank you all 谢谢你们
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.