zoukankan      html  css  js  c++  java
  • Delphi中操作sql代码

    一个例子:

     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;

    另一个例子:

      with qrypx do begin
          close;//    select
          sql.Clear;
          sql.text:='select top 30 dsjbh,qh,zjtype,uphone,uzjsj,checkflag from user_card '
          +'where uzjsj>=:uzjsj and checkflag=0 order by uzjsj,uphone';
          Parameters.ParamByName('uzjsj').Value:=lastzjtime;
          open;
          if recordcount>0 then begin
            while not eof do begin
              Application.ProcessMessages();
              sleep(1);
              if(bExitFlag) then break;
              strqh:=trim(Fieldbyname('qh').AsString);
              strphone:=trim(Fieldbyname('uphone').AsString);
              strdsjbh:=trim(Fieldbyname('dsjbh').AsString);
              strZjtype:=trim(Fieldbyname('zjtype').AsString);//添加装机类型
              zjtime:=Fieldbyname('uzjsj').AsDateTime;

    第三个例子:

              try
       with QryTemp do begin
         if Active then close;
         sql.Clear;
         sql.Text:='select mkbh from haomaduan '
         +'where dsjbh='''+strdsjbh+''' and qh='''+ strqh
         + ''' and ((cast(starthao as bigint)<='+strphone+
          ')and (cast(endhao as bigint)>='+strphone+'))';
         open;
         if recordcount>0 then  result:=trim(fieldbyname('mkbh').AsString)
         else result:='-1'
       end;
     except
       result:='-1';
     end;

  • 相关阅读:
    SAXParseException;前言中不允许有内容的错误
    FATAL Alert:BAD_CERTIFICATE
    DB2的递归
    在Unity中针对屏幕自适应,我们该如何做呢?
    原码与反码的区别?
    在Unity 3D中加入Image图片
    你的外接键盘的小键盘在Num Lock键亮着的,但是数字按了不能用,解决办法在这里
    唯美英文(一)
    如何使用gcc编译器
    C++中const的用法
  • 原文地址:https://www.cnblogs.com/feng801/p/1274221.html
Copyright © 2011-2022 走看看