Migration problem going from TDACDSDataTable to TDAMemDataTable

running version and bin2message

i use .LoadFromRemotesource to pull in records on demand in a TDACDSDataTable
pulling in 1 record at a time
after .LoadFromRemotesource the current record is the one that got pulled in when using TDACDSDataTable, so i can directly manipulate given data

now if i do the same with TDAMemDataTable this code does not work anylonger cause the first record becomes the active one instead of the last record, thus breaking my code and it does not make sence that the first record becomes the selected one…

i’ve looked into the source but i don’t see a direct reason for this, i guess i’ll boil down on how the data is pulled in, didn’t get that far…

the question is: is this the desired behaviour or is this a known issue with TDAMemDataTable?

and further: are there other things to check / take into account when changing from TDACDSDatatable to TDAMemDataTable?

this is a major issue for me…


try to use RDA.Fill method instead.
it does almost the same, but has aAppendMode parameter:

    procedure Fill(aTables: array of TDADataTable; aTableRequestInfoArray: array of TableRequestInfo; aSaveCursor: boolean=false;aIncludeSchema: boolean=false; aAppendMode:Boolean = False); overload;
    procedure Fill(aTables: array of TDADataTable; aWhereClauses : array of TDAWhereExpression; aSaveCursor: boolean=false; aIncludeSchema: boolean=false; aAppendMode:Boolean = False); overload;
    procedure Fill(aTables: array of TDADataTable; aSaveCursor: boolean = False; aIncludeSchema: boolean = False; aAppendMode:Boolean = False); overload; override;

if you look at code, .LoadFromRemotesource calls RDA.Fill internally:

procedure TDADataTable.LoadFromRemoteSource(BookmarkPosition: boolean = False);
  lDataAdapter.Fill([self], BookmarkPosition, FieldCount = 0);

that implies i have to change all code relying on LoadFromRemotesource…
and i don’t see how the behaviour of the CDSDatatable is different since they both derive from tdatatable?

i guess the default for loadfromremotesource (which i find more explanatory then Fill) should be appendmode true?

i mean the call to rda.fill in tdadatatable is the same for CDS as for MEM?


.LoadFromRemoteSource is declared on TDADataTable level (i.e. in base class) and wasn’t changed for ages.

can i rely on the fact that the pulled in record will always be the Last in the dataset?

exactly so why is CDS different in behaviour then?

you may have active indexes and AutoSorting records in Mem table.
you may call LoadFromRemoteSource(True)

can you reproduce this behavior on very simple testcase?

the dataset gets filtered, but before the loadfromremote the tdamem.filter:=false
is filtering creating an index in TdaMem?
otherwise there is no autosorting of index being used explicitly…

Looks like, this code causes

procedure TDAMemoryDataset.SetOnFilterRecord(const Value: TFilterRecordEvent);
  if Active and Filtered then First;

You can use LoadFromRemotesource(True). in this case, the same record will be selected

LoadFromRemoteSource(True) => this will keep the current record before the load as current? so not the pulled in one or position to Last?

selected position before LoadFromRemoteSource will be selected again

but i set filtered to FALSE before the loadfrom call…
and i don’t set the filtered to true before i try to alter the pulled in data…
so that does not apply?

selected position before LoadFromRemoteSource will be selected again

that is not the desired behaviour…
i yet fail to understand the difference in behaviour between CDS and MEM
and the CDS behaviour is the right one imho?

I think, I need simple testcase with both components and similar code that demonstrates this behavior.
after reviewing, I can say what and where is wrong.

complicated code in your project could change default behavior and causes mess because you could adapt it for CDS component many years ago

i understand but then i have to isolate the table, the logic, our base classes … takes time

and it would make sense that the appendmode is surfaced in loadfromremotesource not?
i don’t manipulate the remotedataadapter otherwise…

AppendMode parameter was added after LoadFromRemoteSource was added for supporting TDADataTable.RefreshFromServer method.

btw, this method may do that same as you want, i.e. incremental loading data from server. but it requires DynamicWhere expression for fetching data

that is also requiring a lot of rewrite cause we still have a lot of DA3 tables
this is one of those…
and we use loadfromremotesource a lot… to pull in a record or a set of records based on a parameterized where

let to create a simple testcase with simple code.
I’ll review it and I think that I can suggest how it can be replaced w/o rewriting everything