I realized that I have problems with TMSQuery and OpenDataSets. if TMSQuery has some BeforeOpen code, such as PAramByNAme assignment the dataset returned by OpenDataSets is empty.
But if I remove the code from BeforeOpen and put it just before OpenDataSets it works.
Is this a known isssue? I use sdac 6.1.6
OpenDataSets and BeforeOpen
Re: OpenDataSets and BeforeOpen
Hello,
Such behavior is due to the fact that all SQL commands are "built" into one SQL query and run "simultaneously", that increases performance, and then all the retrieved ResulSets are copied to their DataSets. Now, at this, we don't call the BeforeOpen and BeforeExecute events, therefore parameters set in these methods are not set up and not transferred to the server. We will consider the possibility to modify this behaviour in one of the next versions.
Such behavior is due to the fact that all SQL commands are "built" into one SQL query and run "simultaneously", that increases performance, and then all the retrieved ResulSets are copied to their DataSets. Now, at this, we don't call the BeforeOpen and BeforeExecute events, therefore parameters set in these methods are not set up and not transferred to the server. We will consider the possibility to modify this behaviour in one of the next versions.
Re: OpenDataSets and BeforeOpen
Thanks for the reply.
Anyway just to inform you i noticed that beforeopen is executed for datasets opened with opendatasets.
ParamByName is not working in BeforeOpen if OpenDataSets are used, but other code such this works:
may be you want to consider this when you implement better support for berofreopen and befoerexecute as you mentioned.
Anyway just to inform you i noticed that beforeopen is executed for datasets opened with opendatasets.
ParamByName is not working in BeforeOpen if OpenDataSets are used, but other code such this works:
Code: Select all
// In BeforeOpen on a Dataset opened with OpenDatasets
MSQwuery1.DeleteWhere;
if MyCondition then
MyQuery2.AddWhere(' FIELD ='+IntToStr(MyID))
else
MyQuery2.AddWhere(' FIELD < 3 ')
Re: OpenDataSets and BeforeOpen
Hello,
The BeforeOpen method is called on opening DataSet, which already contains the data retrieved by execution of the "full" SQL from all the DataSets specified in the OpenDataSets method . At this, there occurs opening of the local DataSet, i.e., parameters are filled in, SQL is modified, but commands are not transferred to the server.
The BeforeOpen method is called on opening DataSet, which already contains the data retrieved by execution of the "full" SQL from all the DataSets specified in the OpenDataSets method . At this, there occurs opening of the local DataSet, i.e., parameters are filled in, SQL is modified, but commands are not transferred to the server.
Re: OpenDataSets and BeforeOpen
i wrote that because in your first reply you wrote:
we don't call the BeforeOpen and BeforeExecute events
Re: OpenDataSets and BeforeOpen
Hello,
It was intended, that the method are not called before sending commands to the server.
It was intended, that the method are not called before sending commands to the server.