• delphi把Clientdataset的Delta保存到数据库


     //ATableName-表名, AKeyField-主键,多个主键用;隔开,如 ;pid;times;  from:unit HlsImplBase;
    function THlsImplBase.UpdateTableData(ATableName, AKeyField: AnsiString; var AData: Variant): Boolean;
    var
      LSql: string;
      LDataSet: TDataSet;
      LProvider:  TProvider;
      LErrCount: Integer;
      I: Integer;
    begin
      Result := False;
      if ATableName = '' then Exit;
      if AKeyField = '' then Exit;
     
      LSql := 'select * from ' + ATableName + ' where 1 = 2';
      LDataSet := CreateDataSet(LSql);
      if not Assigned(LDataSet) then Exit;
     
      LProvider := TProvider.Create(nil);
      LProvider.UpdateMode := upWhereKeyOnly;
      LProvider.DataSet := LDataSet;
      AKeyField := LowerCase(AKeyField);
      for I := 0 to LDataSet.FieldCount - 1 do
      begin
        if (LowerCase(LDataSet.Fields[I].FieldName) = AKeyField) or
            (Pos(';' + LowerCase(LDataSet.Fields[I].FieldName) + ';', AKeyField) > 0) then
          LDataSet.Fields[I].ProviderFlags := LDataSet.Fields[I].ProviderFlags + [pfInKey]
        else
          LDataSet.Fields[I].ProviderFlags := [];
      end;
      try
        try
          LProvider.ApplyUpdates(AData, -1, LErrCount);
        except
        end;
        Result := LErrCount = 0;
      finally
        LDataSet.Free;
        LProvider.Free;
      end;
      
    end;
    好的代码像粥一样,都是用时间熬出来的
  • 相关阅读:
    box-sizing
    max-width
    如何编写高质量CSS
    CSS文字大小单位PX、EM、PT
    jQuery设计思想
    pageX,clientX,offsetX,layerX的那些事
    html块级元素和内联元素区别详解
    centos彻底删除mysql
    删:[CentOS 7] 安装nginx
    CentOS7.0安装与配置Tomcat-7
  • 原文地址:https://www.cnblogs.com/jijm123/p/13435256.html
Copyright © 2020-2023  润新知