zoukankan      html  css  js  c++  java
  • delphi --批量添加

    公共批量添加方法

    function BatchSQL(DC : TADOConnection; Qry : TADOQuery; StrSQL : TStrings): Boolean;
    var
      i : integer;
    begin
      Try
        DC.BeginTrans;
        For i := 0 to StrSQL.Count - 1 do
        begin
          With Qry do
          begin
            SQL.Clear;
            SQL.Add(StrSQL[i]);
            Try
              ExecSQL;
              Result := True;
            except
              Result := False;
            end;
          end;
        end;
        DC.CommitTrans;
        Result := True;
      except
        DC.RollbackTrans;
        Result := False;
      end;
    end;
    var 
    
     
    
    tbSql : TStrings;
    
     
    
    tbSql := TStringList.Create;
    with DMW_Public.DQ_Pub do
    begin
      while not Eof do
      begin
        spub_item_content_id:=FieldByName('pub_item_content_id').AsString;
        sInsertXConent:=' insert into set_contents(pub_line_id,pub_item_content_id) '
                +' values ('''+cbb_lines.KeyItems[cbb_lines.ItemIndex]+''','''+spub_item_content_id+''') ';
        tbSql.add(sInsertXConent);
        Next;
      end;
      try
        if BatchSQL(DMW_Public.DC_Pub,DMW_Public.DQ_Pub,tbSql) then
        begin
          ShowErrMsg('配置成功!');
        end else
        begin
          ShowErrMsg('配置失败!');
        end;
      finally
        tbSql.Free;
      end;
    end;
  • 相关阅读:
    十分钟抢票千余张,黄牛的抢票软件是何原理
    常见乱码解决
    如何给程序中的变量起个好名字
    jsp自定义标签
    request.getHeader("Referer")理解【转载】
    mybatis学习笔记1--HelloMybatis
    Spring学习笔记14---bean的使用
    Spring学习笔记13--Autowire(自动装配)
    Spring 学习笔记12--AOP讲解
    Spring学习笔记11--Spring 自动装配 Bean
  • 原文地址:https://www.cnblogs.com/michellexiaoqi/p/7908028.html
Copyright © 2011-2022 走看看