Java Sql Udate error, data type missmatch
- by codo
I have created a table in ms access. I have set the data type of ID to Auto Number in MS-access. In java when I try to update a record. the netBeans IDE gives me the error of " data type missmatch in criteria expression".
But when I changed the ID number that was not in the table already it works well. The code is below.
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);
}