delphi 语法相同的TFDQuery和TADOQuery

sf6xfgos  于 9个月前  发布在  其他
关注(0)|答案(1)|浏览(123)

我想用属性参数扩展类TMyQuery。我想用和使用TADOQuery相同的语法调用TMyQuery。如何正确扩展我的类?

///  new class    
type TMyQuery = class (TFDQuery)
      private
    
        procedure SetParamByName(const Param: TParam);
       public
       ///  here i fail ! 
       property Parameters[const AName: string]: TParam  Write SetParamByName;
    end;
    
procedure TMyQuery.SetParamByName(const Param: TParam);
begin
   // Params.ParamByName(AName). ???  ;
end;    
///  code example    
...
...
///  calling FFDQuery with same syntax like ADO Query     
qryInsert.Parameters.ParamByName('ID').AsInteger := recordCount;

字符串

cygmwpex

cygmwpex1#

你可以试试这样的:

TMyQuery = class (TFDQuery)
  private
    procedure SetParamByName(const AName: string; const Value: TParam);
  public
    /// ...
    property Parameters[const AName: string]: TParam  Write SetParamByName;
  end;

字符串
在执行该程序时,请尝试以下操作:

procedure TMyQuery.SetParamByName(const AName: string; const Value: TParam);
begin
  inherited ParamByName(AName).Value := Value.Value;
end;


你需要这个吗?

相关问题