Page 1 of 1

Dynamic dataset

Posted: Thu 30 Sep 2010 07:45
by gemal
I an old application we currently have to load data for each day of the week.

In the old application we did something like this:

Code: Select all

	MyQuery1->SQL->Clear();
	MyQuery1->SQL->Add("select * from x where day = 1");
	ClientDataSet1->Refresh();
	MyQuery2->SQL->Clear();
	MyQuery2->SQL->Add("select * from x where day = 2");
	ClientDataSet2->Refresh();
	...........
We hit the database 7 times. That's not good. I want to only hit the database once.

So to speed up the application I would like to do something like this:

Code: Select all

	MyQuery->SQL->Clear();
	MyQuery->SQL->Add("select * from x");
and then update the dataset dynamically with only the relevant information (for each day)

so that ClientDataSet1 only would get the date where day = 1 and ClientDataSet2 only would get the date where day = 2 and so on.

Can anybody point me in the right direction to do this?

Posted: Mon 04 Oct 2010 12:58
by AndreyZ
Hello,

You can use filtering like this:

Code: Select all

  MyQuery->SQL->Clear(); 
  MyQuery->SQL->Add("select * from x");
  MyQuery->Open();
  MyQuery->Filter = "day=1";
  MyQuery->Filtered = true;
  ClientDataSet1->Open();
  MyQuery->Filter = "day=2";
  ClientDataSet2->Open();