Hello there,
I’m currently writing a WindowsService to sync some tables between databases. There’s one table which contains a list of produced items with at least two columns: ID (LargeAutoInc) and a serial number (Unique!).
In order to replicate tables with foreign keys on that Table-ID correctly I wrote a function to lookup the DatabaseB.ID for a given DatabaseA.ID (via Serial Number, tiTableInfo holds that information…).
Therefore I have to incrementally load rows for both databases.
While developing this service I had a lot of debug-output written to a text file and everything worked as expected. However after removing this debug output I run into a problem with the following:
[..]
dtMapSource.DynamicWhere.Clear;
dtMapSource.DynamicWhere.Expression :=
DAWhereValue( '', tiTableInfo.MapperTableField, vMappedValue );
if dtMapSource.Active then
dtMapSource.RefreshFromServer
else
dtMapSource.Open;
//if here occurs something, e.g. write log message to a file
//the error will not occur
//--> if I'm using LocateByIndex the row may not be found... I don't know why...
//if NOT dtMapSource.LocateByIndex( tiTableInfo.MapperTableField, vMappedValue ) then
if NOT dtMapSource.Locate( tiTableInfo.MapperTableField, vMappedValue, [] ) then
raise Exception.Create( 'GetMappedID.' + sTablename + ': Could not find row for source value ' + VarToStr( vMappedValue ) + ', ' + dtMapSource.DynamicWhere.Xml );
[..]
The problem didn’t occur until i removed the output to the logfile… If I’m using .Locate instead of .LocateByIndex everythings fine.
How and when are the indizes of a TDAMemDataset refreshed and/or can I enforce an Update (IndexDefs.Update did not solve the problem)?
This method is part of a thread within a windows-service (with connections to multiple DA-Servers).
The tables are not in any special state (ControlsDisabled and so on…)
Thanks in advance,
Peter