0

I have a MyConnection in DataModule1, and MyQuery in Form1. Both components are linked components. Both MyConnection's Connected property and MyQuery's Active property are set to True. Everything is saved. Now I set MyConnection Connected to False, which MyConnection automatically change the MyQuery's Active to False too. DataModule1 was marked by Delphi 7 as "changed" (star symbol next to the file tab) so I can save it, but the problem is Form1 was not. Form1's change in MyQuery does not save even if I clicked on Save button.

As a result, when I re-opened Form1, MyQuery opened with Active property set to True, and it also automatically changes MyConnection's Connected back to True.

I want a solution for this. How can I save Form1 by changing only MyConnection's property? This problem also occurs with "Set Component Properties" tool in GExperts. If I set it to change both MyConnection and MyQuery. Because of this problem it only reported changes to MyConnection but does not "officially" make changes to MyQuery.

Red Romanov
  • 454
  • 5
  • 11
  • Why can't MyConnection set connected true, do you need to change the connection params before connect at runtime? – Kohull Apr 26 '17 at 11:40
  • Delphi always crashes after running something with MyConnection set connected to True. The same goes with MyQuery. – Red Romanov Apr 28 '17 at 01:51

2 Answers2

0

Drag the form a bit, so the position changes and now you can save it.

Basically: change any of the properties of any of the VCL components on the form or the form itself. Even if you change them to the same value this will work and you will get the option to save your form.

Pieter B
  • 1,874
  • 10
  • 22
0

IF the problem is that you forget to set connected to false then there is a better way. You can subclass the connection component and reintroduce the connected property in a way the value does not gets written to the DFM.

So when opening the datamodule (or form) the connection property will alwas be false.

For an ado connection component the source would look like this :

unit adoconnection1;

interface

uses
  SysUtils, Classes, DB, ADODB;

type
  tadoconnection1 = class(TADOConnection)
  private
  protected
  public
  published
    property Connected stored false;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('GuidoG', [tadoconnection1]);
end;

end.
GuidoG
  • 11,359
  • 6
  • 44
  • 79