• 从TdataSet生成OleVariant


    procedure CreateVarArrayFromDataset(var varResultSet: OleVariant;
                                        ADataset : TDataset);
    var
      m : Integer;
      nRecords, nColumns, nCurRec : Integer;
    begin
      nRecords := -1;
      nColumns := -1;

      try
        { Create the array... }
        { Set size to 0..m-1 where m equals the number of columns. }
        nColumns := Max(0, ADataset.FieldCount-1);

        { Each item is an array of size (0..n) where n equals the }
        { number of records.}
        { Entry 0 is where we store the column name. }

        nRecords := Max(0, ADataset.RecordCount);

        varResultSet := VarArrayCreate([0, nColumns, 0, nRecords],
                                       varVariant);

        for m := 0 to nColumns do
          varResultSet[m, 0] := ADataset.Fields[m].DisplayLabel;

        { Populate from result set. }
        ADataset.First;
        nCurRec := 1; { Current record number. }
        while not ADataset.Eof do begin
          { Put in field values. }
          for m := 0 to nColumns do
            varResultSet[m, nCurRec] := ADataset.Fields[m].Value;

          ADataset.Next;
          Inc(nCurRec);
        end;
      except
        on E: Exception do
          raise Exception.Create('CreateVarArrayFromDataset() - ' +
                                  IntToStr(nRecords) +
                                 ' rec,'+IntToStr(nColumns)
                                 +'cols,'+E.Message);
      end;
    end;

  • 相关阅读:
    网易云音乐
    喜马拉雅FM
    喜马拉雅
    169美女图片
    美女图片
    Kerberos简介及常见问题
    【转载】Spark性能优化指南——高级篇
    【转载】 Spark性能优化指南——基础篇
    Sqoop使用手册
    kafka性能基准测试
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/2940989.html
Copyright © 2020-2023  润新知