views:

41

answers:

1

in Delphi 7 , useing TADOQuery. in the contructor i do ADOQuery.open;

then when another function is called from outside the form, the ADOQuery is closed why?

constructor TClass1.Create(AOwner: TComponent;
  MyParam: TProgramParam);
begin
  inherited;
  ADOQuery.Open;
  ADOQuery.Locate('fieldName',Param);  
end;
+2  A: 

My advise to find who is closing the DataSet:

Create a new event handler for the BeforeClose event of the AdoQuery, put anything that is compiled and executed just to put a Breakpoint there. For example:

procedure TfrmCreDocCredito.cdsSucursalesBeforeClose(DataSet: TDataSet);
begin
  ShowMessage('Closing!!');
end;

Run your program, perform any user action needed to create your Class instance and when the program stops on the breakpoint, you have the chance to inspect the call stack. It will reveal who, and if you think a bit about it, you will find why the dataset is closing. If your breakpoint doesn't fire, I bet the dataset never really opens.

Best regards.

jachguate
This is a genius idea, And I hold myself to ask, how didn't think of that myself :) thanks.
none