码迷,mamicode.com
首页 > 其他好文 > 详细

firedac数据集的序列和还原

时间:2016-09-25 20:45:53      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:

procedure TForm1.Button1Click(Sender: TObject);
var
stream, stream2: TMemoryStream;
buf: TBytes;
begin

// 查询
FDQuery1.Close;
FDQuery1.SQL.Clear;
FDQuery1.Open(‘select * from t2‘);

// 序列为流

 

stream := TMemoryStream.Create;
FDQuery1.SaveToStream(stream, TFDStorageFormat.sfBinary);

// 流转换为BUFFER,将BUFFER通过网络分包传输

stream.Position := 0;
SetLength(buf, stream.Size);
stream.Read(buf[0], stream.Size);
stream.Free;

// BUFFER转换为流

stream2 := TMemoryStream.Create;
stream2.Write(buf[0], Length(buf));
stream2.Position := 0;

// 还原出数据

FDMemTable1.LoadFromStream(stream2, TFDStorageFormat.sfBinary);
stream2.Free;
end;

firedac数据集的序列和还原

标签:

原文地址:http://www.cnblogs.com/hnxxcxg/p/5906647.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!