使用update sql语句更新数据库

时间:2014-02-14 15:07:17

标签: java jdbc sql-update

我在更新数据库中的信息时遇到问题 我收到的例外是

  

数据类型不匹配标准表达式

 int p= JOptionPane.showConfirmDialog(null, "Are you sure to update  this patient's details", " Update Patient", JOptionPane.YES_NO_OPTION);
     if(p==0){

        try{
            String  update = "update Patient set PatientID='"+txt_PID.getText()+"',PatientName='"+txt_PName.getText()+"', PatientGender='"+cmb_PGender.getSelectedItem().toString()+"', PatientAge='"+txt_PAge.getText()+"', PatientType='"+ cmb_PType.getSelectedItem().toString()+"',  Patient_Maj_Jop='"+ txt_major_Jop.getText()+"', PatientGSM='"+txt_PGsm.getText() +"',  DateOfReg='"+dch_Date.getDateEditor().getUiComponent().toString() +"'  where PatientID=" + txt_PID.getText();

         ps=con.prepareStatement(update);
         ps.execute();
         JOptionPane.showMessageDialog(null, " Patient details was updated ");
         Update_Table();

     }catch(Exception e  ){
      JOptionPane.showMessageDialog(null, e.getMessage());


     }
    }  

0 个答案:

没有答案