Java Sql Udate error, data type missmatch

Posted by codo on Stack Overflow See other posts from Stack Overflow or by codo
Published on 2012-06-03T05:41:20Z Indexed on 2012/06/03 10:40 UTC
Read the original article Hit count: 157

Filed under:
|
|
|

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);
        }

© Stack Overflow or respective owner

Related posts about java

Related posts about sql