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;

你可能感兴趣的:(中间件)