这是代码:
int value = JOptionPane.showConfirmDialog(Delete_Panel, "Delete Record of '"+rs.getString("Name")+"'", "Delete Now", JOptionPane.YES_NO_OPTION);
它什么都不做..但是当我删除rs.getString("Name")
它时它工作得很好,但我还想在确认对话框中显示来自 ms 访问的名称,然后根据是 no 选项我希望执行我的进一步代码。
完整的源代码是:
String input = txtDelete.getText();
Connection connection;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connection = DriverManager.getConnection("jdbc:odbc:NewPData");
Statement st = connection.createStatement();
ResultSet rs = st.executeQuery("select ID from Table1 where ID=" + input);
if (!rs.next()) {
JOptionPane.showMessageDialog(Delete_Panel, "ID does not exist");
} else {
// int value = JOptionPane.showConfirmDialog(Delete_Panel, "Delete Record of '"+rs.getString("Name")+"'", "Delete Now", JOptionPane.YES_NO_OPTION);
st.executeUpdate("delete from Table1 where ID=" + input);
JOptionPane.showMessageDialog(Delete_Panel, "Record is Deleted");
connection.close();
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
}
}