Copying data from DBXReader to ClientDataSet

Let's share the knowledge with your friends

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:

  Reader: TDBXReader;
  DepClient: TDepartmentClient;
  DepClient := TDepartmentClient.Create(DMClientContainer.MyDSServer.DBXConnection, False);

    Reader := DepClient.GetDepartmentsOrderBy;

      if Assigned(Reader) then
        TDBXDataSetReader.CopyReaderToClientDataSet(Reader, DMClientContainer.CDSCopy);


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

Let's share the knowledge with your friends
3 replies
    • Andreano Lanusse
      Andreano Lanusse says:

      Oi Samuel,

      Vai na unit DBXDBReaders na procedure CopyValueTypeProperties, localize a linha onde está
      if ValueType.DataType = TDBXDataTypes.WideStringType then

      e mude para

      if ValueType.DataType in [TDBXDataTypes.WideStringType, TDBXDataTypes.AnsiStringType] then

      Isso irá resolver o problema de truncar.


Trackbacks & Pingbacks

  1. […] probably already read my post Copying data from DBXReader to ClientDataSet, now is time to learn how copy data from ClientDataSet to DBXReader using Delphi or […]

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.