Recent

Author Topic: Error : Operation cannot be performed on inactive dataset  (Read 1221 times)

essence-ciel

  • Newbie
  • Posts: 6
Error : Operation cannot be performed on inactive dataset
« on: September 18, 2023, 08:23:08 am »
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;

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

  • Hero Member
  • *****
  • Posts: 1084
Re: Error : Operation cannot be performed on inactive dataset
« Reply #1 on: September 18, 2023, 10:14:35 am »
Debug your program: set breakpoints in OnCreate events and similar, then go step by step and see at which point you get error.

TRon

  • Hero Member
  • *****
  • Posts: 1852
Re: Error : Operation cannot be performed on inactive dataset
« Reply #2 on: September 18, 2023, 10:26:32 am »
PS : I'm therapist, not a computer scientist
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

  • Newbie
  • Posts: 6
Re: Error : Operation cannot be performed on inactive dataset
« Reply #3 on: September 18, 2023, 07:36:07 pm »
Hello,
Thanks for the suggestions, I'll get to work on a deeper, event-targeted debugging as suggested.
Have a nice day.

af0815

  • Hero Member
  • *****
  • Posts: 1265
Re: Error : Operation cannot be performed on inactive dataset
« Reply #4 on: September 19, 2023, 08:43:45 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?
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 :-) )
« Last Edit: September 19, 2023, 08:45:30 am by af0815 »
regards
Andreas

essence-ciel

  • Newbie
  • Posts: 6
Re: Error : Operation cannot be performed on inactive dataset
« Reply #5 on: September 20, 2023, 10:28:57 am »
Good evening af0815,

Thanks for the clarification and the explaination. So I understand that I have to open and close the connection and requests on the fly like my forms. It's going to be a sport, given the number of files... 

Thanks again, I'll get to it as soon as I can.

Have a nice evening,

essence-ciel

  • Newbie
  • Posts: 6
Re: Error : Operation cannot be performed on inactive dataset
« Reply #6 on: October 02, 2023, 01:41:07 am »
Ok, It works ! Thanks a lot !

 

TinyPortal © 2005-2018