我有两种方法,一种有效,另一种不适用于插入查询
// this one fails
public void product(String product, String quantity, String price,
String date) throws SQLException {
try {
statement.execute("INSERT INTO product (productn,quantity,price,date) VALUES ('" + product + "','" + quantity + "','" + price + "','" + date + "')");
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
// this one works
public void customer(String name, String q, String p, String pro)
throws SQLException {
try {
statement.execute("INSERT INTO Customer (name,price,product,quantity) VALUES ('" + name + "','" + q + "','" + p + "','" + pro + "')");
} catch (Exception e) {
System.out.println("problem in Customer insert !");
}
}
一种工作正常的方法意味着它将数据插入表中,但另一种方法给出以下错误:
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement