#1 2015-03-24 20:43:14

Junior/RO
Member
Registered: 2011-05-13
Posts: 210

TSynSQLTableDataSet still the best way create a TDataset?

Some years ago, I used TSynSQLTableDataSet to create a TDataset from a FillTable.

I need to create a report from a TSQLRecord descendant in FastReport, now. I see that mORMot have new ways of create TDatasets. There are a better way now?

uses mORMotVCL;

var
  Animal: TSQLAnimal;
begin
  Animal := TSQLAnimal.Create;
  try
    Animal.FillPrepare(DB, 'Nome=?',['Tom']);
    ds1.Dataset.Free;
    ds1.DataSet := <some-thing-to-dataset>(Animal);
    // create my report
  finally
    Animal.Free;
  end;
end;

Last edited by Junior/RO (2015-03-24 20:43:51)

Offline

#2 2015-03-25 13:39:57

Junior/RO
Member
Registered: 2011-05-13
Posts: 210

Re: TSynSQLTableDataSet still the best way create a TDataset?

Arnaud?

Offline

#3 2015-03-25 15:46:11

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,656
Website

Re: TSynSQLTableDataSet still the best way create a TDataset?

You have
- function ToClientDataSet() in mORMotMidasVCL.pas
- TSynSQLTableDataSet.Create() or TSynSQLTableDataSet.CreateOwnedTable() in mORMotVCL.pas

The first uses a TClientDataSet so is slower than the previous, and more memory consuming.
But it could be updated in place, so is read/write.

But the TSynSQLTableDataSet class is a better solution (faster, less memory, no dependency to Midas), for a read-only TDataSet.
So IMHO for filling a report, mORMotVCL.pas is the best option.

Offline

#4 2015-03-25 16:04:55

Junior/RO
Member
Registered: 2011-05-13
Posts: 210

Re: TSynSQLTableDataSet still the best way create a TDataset?

Thank you.

Before I asked this question, I have read the documentation and found ToDataSet() and ToClientDataSet(). But I don't know how to use them with my TSQLAnimal class. The examples show only with direct aProps.Execute(), not in the ORM way.

May I ask you to show a example of aTSQLRecord.FillPrepare + ToClientDataSet()?

Last edited by Junior/RO (2015-03-25 16:05:29)

Offline

Board footer

Powered by FluxBB