Page 1 of 1
RefreshDetail is causing exception (Unidac 6.1.4)
Posted: Tue 30 Jun 2015 11:59
by swierzbicki
Hello,
RereshDetails is causing exception:
"Can not perform this operation on a closed dataset"
Here is a call stack
:7600812f KERNELBASE.RaiseException + 0x54
:005e0cbc DatabaseError + $64
:005f2f26 TDataSet.CheckActive + $36
:00b8fead TCustomDADataSet.CheckActive + $5
:00b94f3a TCustomDADataSet.RefreshDetail + $1E2
I'll try to make a simple reproducible project. Are you aware of the problem ?
Re: VirtualTable is causing exception when calling CheckActive
Posted: Tue 30 Jun 2015 12:36
by AlexP
Hello,
This is a correct error, since it is raised in the TDataSet.CheckActive base method in the standard module DB if the DataSet is dsInactive.
Re: RefreshDetail is causing exception (Unidac 6.1.4)
Posted: Tue 30 Jun 2015 12:39
by swierzbicki
But I never call "CheckActive" ! This is a project that used to worked... and moving from one record to another one raise this error.
Was there any modification with details dataset handling ?
Re: RefreshDetail is causing exception (Unidac 6.1.4)
Posted: Tue 30 Jun 2015 14:36
by swierzbicki
I've stepped into the code and error appears in
Code: Select all
TCustomDADataSet.RefreshDetail(Sender: TObject);
...
try
DoBeforeOpen;
DataReopen;
if Length(FIRecordSet.IndexFields) > 0 then
FIRecordSet.SortItems;
finally
Resync([]);
First; // <==== Exception because dataset is closed
DoAfterOpen;
end;
...
This behaviour was introduced in this version (First call is not present in previous release).
Removing it solves my problem. Is there a specific reason to call "First" ?
Re: RefreshDetail is causing exception (Unidac 6.1.4)
Posted: Wed 01 Jul 2015 08:35
by AlexP
Yes, we have added a call for this method, however, it mustn't cause an error. Please send a small sample reproducing the issue to alexp*devart*com .
Re: RefreshDetail is causing exception (Unidac 6.1.4)
Posted: Wed 01 Jul 2015 12:17
by swierzbicki
You can easily reproduce it :
Create a master/details relation.
On the OnBeforeOpen event of the detail dataset add something like that (in my case, i'm setting SQL script before opening any TUniQuery component) : TUniquery(Sender).Sql.Text := 'Select * from Table';
Demo sended to your email address
Re: RefreshDetail is causing exception (Unidac 6.1.4)
Posted: Wed 01 Jul 2015 12:46
by AlexP
You can't change the SQL text in the OnBeforeOpen event, since this leads to DataSet closing. You can use the BeforeRefresh event for this.
Re: RefreshDetail is causing exception (Unidac 6.1.4)
Posted: Wed 01 Jul 2015 15:48
by swierzbicki
I don't understand why I cannot use the "BeforeOpen" event. This event occurs before an application executes a request to open a dataset, a dataset that is *already* closed. "BeforeRefresh" occurs immediately before an application refreshes the data in the dataset.
Most of my TUniQuery does refresh before / after modifying data... Some of the data are automatically refreshed... Using the "BeforeRefresh" event will definitively not be the right event to choose !
I don't have such errors when working with Master/Details TClientDatasets for exemple. I didn't get these issues whit previous Unidac release and for years now...
I guess that detail dataset linked event in this special case should'nt be triggered at all... Please review your point of view.
Thank you
Re: RefreshDetail is causing exception (Unidac 6.1.4)
Posted: Thu 02 Jul 2015 11:42
by AlexP
We will add a global variable responsible for this behavior, i.e. the BeforeOpen event will be called one time by default (on "real" opening DataSet), as well as in other DataSets.
Re: RefreshDetail is causing exception (Unidac 6.1.4)
Posted: Thu 02 Jul 2015 11:52
by swierzbicki
That's nice. I suppose you will do the same for the other events ?
Re: RefreshDetail is causing exception (Unidac 6.1.4)
Posted: Thu 02 Jul 2015 12:46
by AlexP
No, we won't change behavior for other events.