Filter Problem

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Prompt Systems
Posts: 2
Joined: Wed 05 Oct 2005 19:16

Filter Problem

Post by Prompt Systems » Thu 20 Sep 2007 07:11

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
Last edited by Prompt Systems on Tue 26 Oct 2010 20:37, edited 1 time in total.

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Thu 20 Sep 2007 15:06

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.

Post Reply