Delphi中SQL语句配置参数代码示例

function Tformmain.UpdateUsercardFlag(dsjbh,qh,uphone:string):boolean;//更新用户号码簿中的检查标志
begin
try
   with QryTemp do begin
     if Active then close;
     sql.Clear;
     //    select dsjbh,qh,uphone,zjtype,uzjsj,checkflag from user_card
     sql.Text:='update user_card set checkflag=1 where'
      +' dsjbh=:dsjbh and uphone=:phone and qh=:qh';
     Parameters.ParamByName('dsjbh').Value:=dsjbh;
     Parameters.ParamByName('phone').Value:=uphone;
     Parameters.ParamByName('qh').Value:=qh;
     ExecSQL;
  end;
  result:=true;
 except
   ADOConnection1.Close;
   StatusBar1.Panels[2].Text:='更新失败';
   sleep(200);
   result:=false;
 end;
end;

原文地址:https://www.cnblogs.com/feng801/p/1276697.html