Create Employee Management System using JAVA - Part 17
How to update-Edit a data in SQLite (MySql) Database in Netbeans java
Update Button:
private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) {
try{
String val1 = txt_employeeid.getText();
String val2 = txt_name.getText();
String val3 = txt_surname.getText();
String val4 = txt_age.getText();
PreparedStatement pst = conn.prepareStatement("UPDATE employeeinfo SET "
+ "employeeid='"+val1+"', name='"+val2+"', surname='"+val3+"', age='"+val4+"' WHERE employeeid='"+val1+"'");
pst.executeUpdate();
JOptionPane.showMessageDialog(null, "Updated!");
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}
Update_table();
}
See you on next tutorial 18 - How to clear a JTextField with a button in Netbeans Java!
Post a Comment