ADOQuery.SQL.Text := 'update userInfo set 审核人=''' + GetUserName + ''' where ID=''' + StrToInt(strID)+ '''';先说明一下,上面的 ID 是 int 型字段,审核人 也是数据库字段名,GetUserName 和strID 都是 delphi的 String 类型变量名。怎么会编译出错呢?大家帮我看一下为什么?
而且我试了一下下面这种方法也出错,有点晕,不知道为什么?ADOQuery.SQL.Text := 'update userInfo set 审核人=''' + GetUserName + ''' where ID=''' + strID+ '''';

解决方案 »

  1.   

    ADOQuery.SQL.Text := 'update userInfo set 审核人=''' + GetUserName + ''' where ID=''' + inttostr(strID)+ '''';
      

  2.   

    不好意思,看错了,如果StrID是String类型的话,应该是ADOQuery.SQL.Text := 'update userInfo set 审核人=''' + GetUserName + ''' where ID=''' + strID + '''';
      

  3.   

    在执行SQL前加上showmessage(query1.sql.text);,执行看看ShowMessage的内容是否有错。
      

  4.   

    如果ID是INT型的话,那么 where ID='+StrToInt(strID)+'''';,你上面的好像是给INT型加''了。
      

  5.   

    ADOQuery.SQL.Text := ' update userInfo set 审核人= "' + GetUserName + '"  where  ID=' + strID;
      

  6.   

    ADOQuery.SQL.Text := ' update userInfo set 审核人= ' + QuotedStr(GetUserName) + '  where  ID=' + strID;
      

  7.   

    这是引号的问题,本人在刚用Delphi时也经常遇到.
    ADOQuery.SQL.Text := ' update userInfo set 审核人= "' + GetUserName + '"  where  ID=' + strID;