zoukankan      html  css  js  c++  java
  • 从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;

  • 相关阅读:
    ECMAScript2017之async function
    ES3之closure ( 闭包 )
    RxJS之AsyncSubject
    RxJS之BehaviorSubject
    RxJS之Subject主题 ( Angular环境 )
    RxJS之工具操作符 ( Angular环境 )
    RxJS之转化操作符 ( Angular环境 )
    RxJS之过滤操作符 ( Angular环境 )
    RxJS之组合操作符 ( Angular环境 )
    关于Qt的StyleSheet作用范围
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/2940989.html
Copyright © 2011-2022 走看看