Not to sure what I am missing here but nothing seems to be working for me. I tried several approaches and none seemed to work. Any idea?
Here is my Code:
btnUpdate = new JButton("Update");
btnUpdate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String pid = textIDField.getText();
String fn = textFNameField.getText();
String ln = textLNameField.getText();
String add = addressField.getText();
String city = cityField.getText();
String phone = phoneField.getText();
String mid = medIDField.getText();
try{
Connection conn = DriverManager.getConnection("dbinfo");
String query = "UPDATE Patient SET PatID=?,FirstName=?,LastName=?,Address=?,City=?,Phone=?,MedID=? WHERE PatID=? AND MedID=?";
PreparedStatement pst = conn.prepareStatement(query);
pst.setString(1, pid);
pst.setString(2, fn );
pst.setString(3, ln );
pst.setString(4, add );
pst.setString(5, city );
pst.setString(6, phone );
pst.setString(7, mid );
pst.executeUpdate();
JOptionPane.showMessageDialog(null, "Patient Updated");
pst.close();
}catch(Exception ex){
ex.printStackTrace();
}
}
});