LexarG56

Generation

generate functionWed, 19 Jul 2023

En el btnEliminarActionPerformed quiero que se pueda eliminar un estudiante de una tabla con solo el codigo del estudiante

private void btnEliminarActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: int fila = tbEstudiantes.getSelectedRow(); String cod = ""; cod = tbEstudiantes.getValueAt(fila, 0).toString(); if (fila >= 0) { try { PreparedStatement pps = cn.prepareStatement("DELETE FROM estudiantes WHERE cod_est ='" + cod + "'"); pps.executeUpdate(); JOptionPane.showMessageDialog(null, "Dato Eliminado"); mostrardatos(""); } catch (SQLException ex) { Logger.getLogger(Interfaz.class.getName()).log(Level.SEVERE, null, ex); } } }

Questions about programming?Chat with your personal AI assistant