FIREDAC调用中间件远程方法查询数据示例

服务端使用FDQUERY查询数据并返回TDATASET:

function TServerMethods1.GetData(var sql: string): tdataset;
begin
qry.Close;
qry.Open(sql);
Result := TFDMemTable.Create(nil);
TFDMemTable(Result).Data := qry.Data;
end;

客户端用FDCONNECTION连接中间件,FDStoredProc访问远程方法:

procedure TForm1.Button1Click(Sender: TObject);
begin
FDConnection1.Connected := true;
FDStoredProc1.Close;
FDStoredProc1.Unprepare;
FDStoredProc1.StoredProcName := 'TServerMethods1.GetData';
FDStoredProc1.Prepare;
FDStoredProc1.ParamByName('sql').Value := 'select * from bas_goods';
FDStoredProc1.open;
FDMemTable1.Close;
FDMemTable1.Data := FDStoredProc1.Data;
FDStoredProc1.Close;
end;

posted @ 2014-09-15 22:15  delphi中间件  阅读(5879)  评论(2编辑  收藏  举报