Question

How can I easily move data from TDataSet to TClientDataSet? I need XML representation of the data in TClientDataSet.XMLData property.

Was it helpful?

Solution

Drop a TDataSetProvider onto the form or datamodule with the ClientDataSet, set the ClientDataSets property ProviderName to the name of the TDataSetProvider. Set the DataSet property of the TDataSetProvider to the other dataset. Open the ClientDataSet.

OTHER TIPS

This is from the perspective of a TClientDataset derivative.

procedure TMyClientDataset.CopyFromDatasetProvider(Dataset: TDataset);
 var DataSetProvider : TDataSetProvider;
begin
  DataSetProvider := nil;
  try
    Close;
    DataSetProvider := TDataSetProvider.Create(nil);
    DatasetProvider.Options := [poNoReset];
    StoreDefs := False;
    DataSetProvider.DataSet := Dataset;
    SetProvider(DataSetProvider);
    Open;
    First;
    SetProvider(nil);
   finally
    if Assigned(DataSetProvider)
     then DataSetProvider.Free;
   end;

end;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top