【发布时间】:2012-06-03 05:41:20
【问题描述】:
我在 ms 访问中创建了一个表。我在 MS-access 中将 ID 的数据类型设置为自动编号。在 java 中,当我尝试更新记录时。 netBeans IDE 给了我“标准表达式中的数据类型不匹配”的错误。 但是当我更改表中没有的 ID 号时,它运行良好。代码如下。
String sql = "Update table1 set price ='" + txtPrice.getText() + "', quantity='" + txtQuantity.getText() + "', description='" + txtDescription.getText() + "' where id= " + txtid.getText() + "";
try {
pst = conn.prepareStatement(sql);
pst.executeUpdate();
JOptionPane.showMessageDialog(null, "Updated");
UpdateJTable();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
【问题讨论】:
-
如果您收到错误,最好发布堆栈跟踪。