0
private void addCustomerActionPerformed( ActionEvent e )
{   
   String Query;
   Query = "INSERT INTO Membership VALUES"+ "(' " +memberID_a.getText() + " ' , ' " +memberName_a.getText() + " ' , ' " + icNo_a.getText()  + " ', ' " + gender_a.getText()  +" ' , '" + birthday_a.getText()  +" ' , ' " + telephoneNo_a.getText()  + " ',' " + mobileNo_a.getText()  + " ' , ' " + email_a.getText()  + " ' , ' " + address_a.getText()  + " ' , " + postalCode_a.getText() + " ,' " + state_a.getText()  + " ' , '" + country_a.getText()  + " ' , " + memberPoint_a.getText() + ");";


       try {

           stmtInsert = conn.createStatement(); 
           stmtInsert.executeUpdate(Query);


        } catch(Exception ex){
             JOptionPane.showMessageDialog(null,"ERROR"+ex.toString(),"ERROR",JOptionPane.ERROR_MESSAGE);
        }
   } 

我得到的错误

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] INSERT INTO 语句中的语法错误。

有人帮我解决这个问题吗?谢谢

4

1 回答 1

0

这将起作用

Query ="INSERT INTO Membership VALUES ( " +memberID_a.getText() + " , " +memberName_a.getText() + " , " + icNo_a.getText()  + " , " + gender_a.getText()  +" ," + birthday_a.getText()  +"," + telephoneNo_a.getText()  + " , " + mobileNo_a.getText()  + " , " + email_a.getText()  + " , " + address_a.getText()  + " , " + postalCode_a.getText() + ", " + state_a.getText()  + " ," + country_a.getText()  + "," + memberPoint_a.getText() + ")";
于 2013-07-02T16:48:13.653 回答