0

I have application that has ADO connection on main form and several plugins that have ADO queries which I connect to this main connection. One problem is that I can't properly design those plugins without their personal connection which becomes messy when I connect plugins to main app. One plugin has plenty of queries.

I can use ConnectionObject to pass plugin's queries through main connection, but this is non-convenient for me, because when main connection needs to reconnect, I can't automatically reconnect all the queries. So I have to reassign those plugins' Connection property to main connection after plugin creation.

I know that one can list all active queries using ADOConnection's DataSets property. But what property should I use if I want to list both active and inactive DataSets? The IDE lists them automatically in designer, so I think there should be a generic way to do this.

Danatela
  • 349
  • 8
  • 28
  • 1
    I've checked and indexed property `DataSets` is a collection of all datasets (active and inactive) linked to a given connection. You would have to provide us some code if it does not work for you. – Wodzu Apr 22 '15 at 12:04
  • Indeed. Yesterday I didn't check how does `TADOConnection.RegisterClient` method work. Today I found that you are right. Though guides that I found over Internet told me straight that `DataSets` are only active datasets. Anyway, you can post your comment as correct answer. – Danatela Apr 23 '15 at 02:59
  • Done, I've extended my answer a little bit. – Wodzu Apr 23 '15 at 06:18

1 Answers1

3

Perhaps documentation regarding TADOConnection.DataSets which can be found here has confused you.

It says:

Use DataSets to access active datasets associated with a connection component.

This might leed to thinking that DataSets keeps only active datasets which is not the case. To test this, just put one TADOConnection and one TADOQuery component on a form and set up TADOQuery.Connection to the instance of your connection, for example ADOConnection1.

To test that DataSets property keeps also inactive datasets you might use this code:

procedure TForm1.FormCreate(Sender: TObject);
var
  i: Integer;
begin
  for i := 0 to ADOConnection1.DataSetCount - 1 do
  begin
    if not ADOConnection1.DataSets[i].Active then
      ShowMessage('Inactive dataset!');
  end;
end;
Wodzu
  • 6,932
  • 10
  • 65
  • 105