Here is the actionMouseClic ked. It should be able to update the selected row with new data from a form.
The updating works for the most part I.e It updates all data in one column to the same data (which is fine as long as I can get the SQL to work)
I need it so the SQL statement recognizes the ComboBox selection and updates the database accordingly.
The updating works for the most part I.e It updates all data in one column to the same data (which is fine as long as I can get the SQL to work)
I need it so the SQL statement recognizes the ComboBox selection and updates the database accordingly.
Code:
private void addBtnMouseClicked(java.awt.event.MouseEvent evt) {
String CBox2 =(String)comboBoxCS.getSelectedItem();
String sql = "update carstock set CarStock = ? where DriverID = ('CBox2')";
try{
pst = conn.prepareStatement(sql);
pst.setString(1, addRemove.getText());
pst.executeUpdate();
JOptionPane.showMessageDialog(null, "Updated");
UpdateJTable();
}
catch (Exception e){
JOptionPane.showMessageDialog(null, e);
}
}
Comment