Menambahkan Form Konfirmasi Delete di Java
java konfirmasi delete |
Pertama : Buatlah variable msg seperti berikut:
int msg=JOptionPane.showConfirmDialog(null,"Do you really wan to delete ?"
,"Delete",JOptionPane.YES_NO_OPTION );
Kedua : Buatlah kondisi IF seperti berikut dan letakkan perintah action delete (yg tidak dicetak tebal) jika msg==0
lihat kode berikut:
if(msg==0){
try{
String sql="delete from db_user where"
+ "where id_user=?";
ps=(PreparedStatement) conn.prepareStatement(sql);
ps.setInt(1,76 );
ps.execute();
glasspaneMessage.setMessage("Data Deleted");
}catch(SQLException | HeadlessException e){
JOptionPane.showMessageDialog(null, e);
}
}
0 comments:
Post a Comment