远程方法的定义和调用

xe datasnap自动支持TParams对象的序列,无需我们手动序列,真的很方便。

远程方法定义示例:

function TServerMethods1.GetData(sql: string;
  params: TParams): TDataSet;
begin
  cds.Close;
  cds.CommandText := '';
  cds.CommandText := sql;
  cds.Params.Clear;
  cds.Params := params;
  cds.Open;
  Result := cds;
end;

客户端远程调用示例:

function TMySQL.GetData: TDataSet;
begin
  fSqlMethod.ServerMethodName := 'TServerMethods1.getData';
  fSqlMethod.ParamByName('sql').AsString := fSqlcommand;
  fSqlMethod.ParamByName('params').AsParams := fQry.Params;
  fSqlMethod.ExecuteMethod;
  Result := fSqlMethod.ParamByName('returnparameter').AsDataSet;
end;

 

posted @ 2012-02-12 07:16  delphi中间件  阅读(960)  评论(1编辑  收藏  举报