I recently updated an old Delphi project to separate the creation of its data module and opening of that module's TDatabase
, TTable
and TClientDataSet
components from the creation and showing of the app's form. Now, the app can toggle on and off the data components of the app. This new capacity isn't critical of course, but is "nice to have." My tool chain is RS v21 (the marketing version 10.4.1).
Yet there's a problem: after closing and reopening the data components from the UI, data aware controls show no data. Tests show that the underlying tables are open, can be navigated, and field values can be retrieved programmatically.
I've also established that resetting a data aware component's DataSource
restores its display of underlying field data.
NB: data aware controls' DataSource
are set at design time and, at run time after closing and reopening data tables, are not nil
.
I conclude that resetting DataSource
has a side effect -- probably tickling the DataLink
within.
You can imagine I would like a means to obviate the need to reset a whole bunch of DataSource
s. The easy hopes that TDataSet
methods like Refresh
all fail. ;-)
A sketch of the coding inside the app's form looks like this -- to open:
dm:=Tdm.Create(nil);
dm.OpenDatabase;
dm.OpenDataTables;
And closing is the reverse:
dm.CloseDataTables;
dm.CloseDatabase;
dm.Free;
dm:=nil;
In the database Tdm
: In design, the datasets are not active, and the database is not connected. Tdm.OpenDatabase
envokes Open on the TDatabase; Tdm.OpenDataTables
runs through the needed tables using their Open
method. Tdm.CloseDatabase
and Tdm.CloseDataTables
are symmetrical.
Thank you for any insights.