Page 1 of 1

duplicate queries

Posted: Thu 29 Jul 2010 09:33
by geanni
Hi,

I am relatively new in using myDac VCL components and I have a problem: I use a MyQuery -> TClientDataset to populate a Grid. The code is similar with this:

MyQuery1->SQL->Text = "Select * from table1";
if(MyQuery1->Active == false)
MyQuery1->Active = true;

if(ClientDataSet1->Active==false)
ClientDataSet1->Active=true;

ClientDataSet1->Filter = "field1 = 'dummy'";
ClientDataSet1->Filtered = true;
ClientDataSet1->Refresh();

The problem is that after ClientDataSet1->Refresh() it is queried two timesthe server with exactly the same query( I see it with dbMonitor). I don't understand why. Can anyone give a solution to overcome this problem?

Thanks in advanced,
Geanni

Posted: Thu 29 Jul 2010 14:27
by Dimon
To solve the problem you should not set MyQuery1.Active to True. Just delete the following code:
if(MyQuery1->Active == false)
MyQuery1->Active = true;

Posted: Wed 04 Aug 2010 10:20
by geanni
thanks
This solved my problem :)