Nathan De Lima
Nathan De Lima

Reputation: 17

Netbeans Java - You have an error in your sql syntax

I'm getting this error when I go to update my database.Error I'm getting

This is what my database looks like Database

And here is my code:

private void updatebtnActionPerformed(java.awt.event.ActionEvent evt) {

    try{
    String mid = midtxt.getText();
    String fname = firstnametxt.getText();
    String lname = lastname.getText();
    String nic = nictxt.getText();
    String Address = addresstxt.getText();
    String Telephone = telephonetxt.getText();   


    DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    jXDatePicker1.setFormats(dateFormat);
    DateFormat sysDate = new SimpleDateFormat("yyyy/MM/dd");
    String Dob  = sysDate.format(jXDatePicker1.getDate());



   String sql = "UPDATE `addmember` SET `FirstName`='"+fname+"',LastName`='"+lname+"',`NIC`='"+nic+"',`DOB`='"+Dob+"', `ADDRESS`='"+Address+"', `Telephone`='"+Telephone+"' WHERE MID='"+mid+"' ";
      try{
            Updater(sql);
            JOptionPane.showMessageDialog(null, "Values Updated");
        }
        catch( Exception ex){
            JOptionPane.showMessageDialog(null, ex);
        }
    }

    catch(Exception ex){
        JOptionPane.showMessageDialog(null, ex);
    }
}                                         

Upvotes: 0

Views: 1179

Answers (1)

kagmole
kagmole

Reputation: 2165

Missing backtick before LastName.

Upvotes: 1

Related Questions