标签:
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;
标签:
原文地址:http://www.cnblogs.com/hnxxcxg/p/5906647.html