Datasnap Remote method return Tstream positive solution (to chant South brother)

Source: Internet
Author: User

Datasnap Remote method returns Tstream positive solution

Datasnap Remote method returns Tstream, if the data size exceeds 32K will be an error. Many delphier are planted on the top and even begin to doubt the viability of Tstream returning data.

Because the Datasnap remote method returns Tstream, the packet size has a maximum limit of 32K.

How to solve? The client wants to do and package the processing.




functionCopyStream (Constastream:tstream): Tmemorystream;Constlbufsize=$F;varlbuffer:tbytes; Lreadlen:integer;beginResult:=Nil;ifAstream =Nil ThenExit; Result:= Tmemorystream.Create;TryifAstream.size =-1 ThenbeginSetLength (Lbuffer, lbufsize);RepeatLreadlen:= Astream.read (lbuffer[0], lbufsize);ifLreadlen >0 ThenResult.writebuffer (lbuffer[0], lreadlen);ifLreadlen < Lbufsize Then Break;untilLreadlen <lbufsize;EndElseResult.copyfrom (Astream,0); Result.position:=0;exceptResult.free;End;End; procedureTform1.btnqry3click (sender:tobject);varLstream:tstream; Lmemstream:tmemorystream;beginDatasource1.dataset:=FDMemTable1; Lstream:= methods. QUERYSQL3 ('0','SELECT * from T1');ifLstream <>Nil ThenbeginLmemstream:=CopyStream (Lstream); Fdmemtable1.loadfromstream (Lmemstream, tfdstorageformat.sfbinary); Lmemstream.free;End;End;

Datasnap Remote method return Tstream positive solution (to chant South brother)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.