***How To UpDate JTable on Delete Command and if given id don't match with database then a message show "id is not available "
My Codes as follows:-***
private void Sf_Reg_delete_ButtonActionPerformed(java.awt.event.ActionEvent evt) {
String str2 = JOptionPane.showInputDialog(null, "Please Note that this Reg No is not generated again : ","Enter Reg No For Delete", 1);
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:HMS_DS","","");
sql="DELETE from Staff_Reg WHERE sf_Reg_No = '"+str2+"'";
stmt=con.createStatement();
int delete = stmt.executeUpdate(sql);
if(str2.equals(""))
{
JOptionPane.showMessageDialog(null,"Please Enter Reg No.");
}
else
{
if(delete == 1)
{
JOptionPane.showMessageDialog(null,"Record Is Deleted.");
}
else
{
JOptionPane.showMessageDialog(null,"Reg No Not Found..");
}
}
UpdateData_Table();
}
catch(Exception ex)
{
//JOptionPane.showMessageDialog(null,ex);
JOptionPane.showMessageDialog(null,"Record Can Not Be Deleted.");
}
}