msgpack配合FIREDAC传输多表数据
Posted hnxxcxg
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了msgpack配合FIREDAC传输多表数据相关的知识,希望对你有一定的参考价值。
msgpack配合FIREDAC传输多表数据
procedure TForm1.Button1Click(Sender: TObject);
var
ms, ms2: TMemoryStream;
pack: TSimpleMsgPack;
begin
ms := TMemoryStream.Create;
FDQuery1.SaveToStream(ms, sfBinary); // FDQuery1数据序列为流
ms2 := TMemoryStream.Create;
FDQuery2.SaveToStream(ms2, sfBinary); // FDQuery2数据序列为流
pack := TSimpleMsgPack.Create;
pack.ForcePathObject(‘table1‘).LoadBinaryFromStream(ms); //msgpack加载流
pack.ForcePathObject(‘table2‘).LoadBinaryFromStream(ms2); //msgpack加载流2
pack.EncodeToStream(); //msgpack转为流后,网络传输流
pack.DecodeFromStream(); //客户端接收流后,流转为msgpack
pack.ForcePathObject(‘table1‘).SaveBinaryToStream(ms);
pack.ForcePathObject(‘table2‘).SaveBinaryToStream(ms2);
FDMemTable1.LoadFromStream(ms); //还原数据
FDMemTable2.LoadFromStream(ms2);
end;
以上是关于msgpack配合FIREDAC传输多表数据的主要内容,如果未能解决你的问题,请参考以下文章