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驱动程序] INSERT INTO语句中的语法错误。
有人帮我解决这个问题吗?感谢
答案 0 :(得分: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() + ")";