Forum > Databases
Error : Operation cannot be performed on inactive dataset
essence-ciel:
Hello everyone,
I'm working with Windows 10/11, Lazarus version 2.2.6, FPC version 3.2.2, Sqlite version 3.43.1, ZEOS dbo (last version) and I'm migrating an application from Delphi 11.3 to Lazarus.
My application contains about 60 data files, many of them with reference fields (to secure data entry). Several times, I've patiently recreated all the forms, and set up 2 datamodules (1 for the "reference" data files, 1 for the "details" files), but I always encountered the same error message. This program, developed with Delphi, has been my working program for over 15 years now. I use it daily and I want to leave embarcadero and his Delphi.
Whereas all my data files are opened when the program is launched, my forms (there are 30 of them) are created on the fly, i.e. when I need them, then closed by the standard procedure...
--- Quote ---procedure Tfsoins64.MRepVMolecClick(Sender : Tobject);
begin
FRepVMolecule64 := TFRepVMolecule64.Create(Self);
FRepVMolecule64.ShowModal;
FRepVMolecule64.Free;
End;
--- End quote ---
But data files stay open, they are closed when I quit program.
Example: plant file (Produits more than 4000 plants) which "points" to a file listing the various plant families (Botanique about 300 records and other files). My "reference" files (30) can contain between 2,000 and 6,000 records each, and my "detail" files several tens of thousands, with the main file (Chromato) reaching 150,000 records.
The form detailing the various plants and their virtues in various galenic forms (one form per galenic form) contains 21 dBGrids spread over several pages of one PageControls. At the design stage, everything looks good.
When I look at the .lfm of the module managing the largest form (58,000 lines), and even though I'm using dBLookUp, I'm surprised to see that all the "reference" files are included in the PickList .lfm file (see attached .lfm file)... Is it the origin of the problem ?
Although, for practical reasons and display speed, as saying, all my data files are opened when the main form is created, I get the following error every time: "Operation cannot be performed on inactive dataset" at attempt of execution.
Please, how can I overcome this error, which causes the program to freeze?
Best regards,
PS : I'm therapist, not a computer scientist
dseligo:
Debug your program: set breakpoints in OnCreate events and similar, then go step by step and see at which point you get error.
TRon:
--- Quote from: essence-ciel on September 18, 2023, 08:23:08 am ---PS : I'm therapist, not a computer scientist
--- End quote ---
Something like that was clear from your colourful description(s). fwiw though nice to read it does not help a single bit with describing the actual problem or what might cause it.
user dseligo is right in that you must make a pragmatic/logic approach in order to try and locate the issue. From your description it is clear that even a single event assigned at the wrong time and/or at the wrong place is able to trigger such an error message. The lfm file that you posted is not going to help with that as it depends on the flow of your code (as well).
essence-ciel:
Hello,
Thanks for the suggestions, I'll get to work on a deeper, event-targeted debugging as suggested.
Have a nice day.
af0815:
--- Quote from: essence-ciel on September 18, 2023, 08:23:08 am ---Although, for practical reasons and display speed, as saying, all my data files are opened when the main form is created, I get the following error every time: "Operation cannot be performed on inactive dataset" at attempt of execution.
Please, how can I overcome this error, which causes the program to freeze?
--- End quote ---
Normal this kind of error happens, if you create and open the queries by automatic. To avoid such problems the best way is to make the connection and open the queries by your code and never set a query/connection to active on startup.
The reson is simple, it can work, but a little change in the code or creation order of/in the forms can went things to bad and this is not direct in your hand. So my design goal is. Connection to database and the activate of queries is always in my controlled code.
dseligo is rigth with the debugging, but this is like a pathologist ( he knows/find all, but a little to late :-) )
Navigation
[0] Message Index
[#] Next page