服务器端:
function TSvrMet.QuerySqlToStream(const cMess, sql: String; account: integer): TStream;
begin
d.fdQry.Close;
d.fdQry.sql.Text := sql;
d.fdQry.Open;
Result := TMemoryStream.Create;
d.fdQry.SaveToStream(Result, TFDStorageFormat.sfBinary);
Result.Position := 0;
end;
客户端:
var DataSnapClient: TSvrMetClient;
Stream: TStream;
begin
DataSnapClient := TSvrMetClient.Create(SQLConn.DBXConnection);
Stream := DataSnapClient.QuerySqlToStream('', 'select * from GLFMKHJL', 1);
try
Stream.Position := 0;
FDMemTable1.Close;
FDMemTable1.LoadFromStream(Stream, TFDStorageFormat.sfBinary);
finally
//Stream.Free;//报错:invalid pointer operation,因为非此处创建则不必释放
DataSnapClient.Free;
end;
end;