• delphi OleVariant转换RecordSet


    delphi OleVariant转换RecordSet

     uses Data.Win.ADODB;

    function varToRecordSet( parms : OleVariant )  : Data.Win.ADODB._Recordset;
      begin
        Result := IDispatch( parms ) as Data.Win.ADODB._Recordset;
    
      end;
    
    function RecordSetToVar( prs : _Recordset ) : OleVariant;
    
      begin
        Result := prs;
      end;
    function recordSetToXMLString(prs:winapi.ADOInt._Recordset): string;
      var
      astr:string;
      stream:TStringStream;
      begin
       stream := TStringStream.Create('');
    
       prs.Save(TStreamAdapter.Create(stream) as IUnknown,adPersistXML);
       stream.Position:=0;
       astr:=stream.DataString;
       stream.Free;
       Result := astr;
    
      end;
    
      function xmlStringToRecordSet(pxml:string): _Recordset;
      var
      drs:Data.Win.ADODB._Recordset;
      irs:winapi.ADOInt._Recordset;
      RS: Variant;
      stream:TStringStream;
      begin
         stream := TStringStream.Create(pxml);
         stream.Position:=0;
         RS := CreateOleObject('ADODB.Recordset');
          RS.Open(TStreamAdapter.Create(stream) as IUnknown);
    
         Result := IUnknown(RS) as winapi.ADOInt._Recordset;
      end;

    ids: IDispatch;

     ADODataSet1.Recordset :=  ids  as _Recordset;

  • 相关阅读:
    在Window上Vim包的选择
    如何在apache官网下载将将jar包
    hdu1870
    hdu1710(Binary Tree Traversals)
    poj 3252 Round Numbers 【推导·排列组合】
    3905
    Find them, Catch them
    Argus
    Team Queue
    Terrible Sets
  • 原文地址:https://www.cnblogs.com/cb168/p/4945794.html
Copyright © 2020-2023  润新知