Page 1 of 1

Filter Problem

Posted: Thu 20 Sep 2007 07:11
by Prompt Systems
Hello!

I really hope you can help me, since it's not a problem of your components.

I used a DBGrid to show the result of a SQL Query. My programm allows to filter this Result (for example lets say only show entryes marked as "green".

With a popup menu I gave the possibility to change the "color".
This ist the way I did it (found this solution here in the forum as one of your developepr suggested to another user)

Code: Select all

MyQuery1->SQLRefresh->Text = GetListQuery(MyQuery1->FieldValues["id"]);
MyQuery1->Edit();
  MyQuery1->FieldValues["Favorite"] = "1";
MyQuery1->Post();
This works out so far good, but if a filter of the color is set, of course the DBGrid should no longer show this entry anymore. But instead I get this error: "Refresh failed. Found 0 records."
I can imagine the problem but yet could not find a way to solve this.

So may I please ask for your help?

Regards

Posted: Thu 20 Sep 2007 15:06
by Antaeus
The SQLRefresh is used to perform refreshing of a single (current) record, for example when you call the RefreshRecord method. So, this statement must return only one record. The error you get means that this query returns no rows. You should check wether it is correctly generated.

There are two ways to perform ordering:
- local ordering (all records are fetched to the client, but only records matching a condition are shown). You can initiate it by the Filter and Filtered properties;
- server ordering (each time the condition changes, a new record set is retrieved to the client). You can initiate it by queries with parameters, or setting the FilterSQL property.