If you are using DataSnap 2010/XE for sure use DBXFramework, which I strong recommend for operations where you don’t use Data Aware components or bi-directional datasets.
There are situations where you will need to copy data from DBXReader to TClientDataSet or TParams, for this kind of situation Delphi has the unit DBXDBReaders.pas, which contain some classes that allow this kind of operation.
The TDBXDataSetReader class contain the method CopyReaderToClientDataSet, on this method you pass the DBXReader that contain the data to copy to the ClientDataSet, which is the second parameter, the follow code demonstrate that:
var Reader: TDBXReader; DepClient: TDepartmentClient; begin DepClient := TDepartmentClient.Create(DMClientContainer.MyDSServer.DBXConnection, False); try Reader := DepClient.GetDepartmentsOrderBy; try if Assigned(Reader) then begin TDBXDataSetReader.CopyReaderToClientDataSet(Reader, DMClientContainer.CDSCopy); end; finally FreeAndNil(Reader); end; finally DepClient.Free; end;
The ClientDataSet CDSCopy already exist and is part of the DataModule DMClientContainer. if you don’t have a ClientDataSet created, use the method TDBXDataSetReader.ToClientDataSet, it wil return a new ClientDataSet.
My DataSnap 2010 samples was updated and you can download from here
Related Posts
Andreano Lanusse | Technology and Software Development
Follow me on Twitter: @andreanolanusse