Components for Delphi and C++ Builder.

Go to Russian forum
Go to EhLib.com
It is currently 20 Apr 2024, 06:00

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: 16 May 2013, 08:30 
Offline

Joined: 22 Apr 2012, 18:35
Posts: 21
Hello

I have a memtable connected to a DataSetDriverEh connected to a TRxQuery.
One of the fields of memtable is calculated.
When I open the memtable, putting a stop in code, I found that OnCalcFields Event of memtable runs twice and as a result memtable needs double time to open.
Why is that?

EhLib V 5.4

Best Regards
Nicholas


Top
 Profile  
 
PostPosted: 05 Jun 2013, 18:55 
Offline
Администратор

Joined: 22 Dec 2011, 20:19
Posts: 335
Hello

It is not good idea to use Calc Fields for long calculations.
DataSet doesn't guarantee that OnCalcFields would be called only once on open.
DataSet calls OnCalcFields even when you go throw the dataset (Next, Prev).
and calculate Calc fields on the fly.

I would advice to use DataDriverEh.OnReadRecord event.
I is called once for every record that MemTableEh gets from DataDriverEh.

Create new physical field in MemTableEh that you will fill by calculation:

This is the expample of using the event:

Code:
procedure TfFishForm.DataSetDriverEh1ReadRecord(DataDriver: TDataDriverEh;
  MemTableData: TMemTableDataEh; MemRec: TMemoryRecordEh;
  var ProviderEOF: Boolean);
begin
// Call standart reading method
  DataDriver.DefaultReadRecord(MemTableData, MemRec, ProviderEOF);

// Calc and assign new fields
// 'NewField' = 'VendorName' + ' (' + 'Address1' + ')'
    MemRec.DataValues['NewField', dvvValueEh] :=
      VarToStr(mtVendors['VendorName']) + ' (' + VarToStr(mtVendors['Address1']) + ')';
  end;
end;

Best regards
Admin

_________________
Best regards
Admin


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group