Hi again, I have read the article that you suggested, and I came up to this problem. I have successfully made a prompt for delete confirmation that lets you choose YES and NO, but the problem is that, even if I chose the option NO, it still deletes the record, it's like same function as the first option (YES button).
So uhmn I just want to clarify if something is wrong with my codes, I'm just new to java and this is one of our assignments. I'm really having hard time figuring this out. I hope you can help me with this one too. Thanks so much!
datacon.GetConnection();
JOptionPane.showConfirmDialog(null, "Delete Record?", "Delete Confirmation", JOptionPane.YES_NO_OPTION);
int n = 0;
if ( n == JOptionPane.YES_OPTION ){
String q = "DELETE from info WHERE ( IDno = '" + jComboBox1.getSelectedItem() +"')";
try
{
st = datacon.GetConnection().createStatement();
st.executeUpdate(q);
st.close();
datacon.GetConnection().close();
JOptionPane.showMessageDialog(null, " Successfully Deleted!");
}
catch(SQLException ex)
{
JOptionPane.showMessageDialog(null, ex.getMessage());
}
firstn.setText(null);
middlen.setText(null);
lastn.setText(null);
eadd.setText(null);
hadd.setText(null);
city.setText(null);
zip.setText(null);
country.setText(null);
hphone.setText(null);
workphone.setText(null);
sss.setText(null);
hiredate.setText(null);
salary.setText(null);
dept.setText(null);
supervisor.setText(null);
econtact.setText(null);
ephone.setText(null);
}
else if ( n == JOptionPane.NO_OPTION ){
firstn.setText("");
middlen.setText("");
lastn.setText("");
eadd.setText("");
hadd.setText("");
city.setText("");
zip.setText("");
country.setText("");
hphone.setText("");
workphone.setText("");
sss.setText("");
hiredate.setText("");
salary.setText("");
dept.setText("");
supervisor.setText("");
econtact.setText("");
ephone.setText("");
}
}