Link to home
Start Free TrialLog in
Avatar of hrvica5
hrvica5Flag for Croatia

asked on

Filter TclientDataSet

Hi,

I have problem with filtering widestring data on TClientDataSet.
If There is widestring it cannot be filtered.

Here is app where you can see the issue.
Filter.zip

Please Help, Thank you
Avatar of Ferruccio Accalai
Ferruccio Accalai
Flag of Italy image

What's the matter really? Because testing your example works fine both for widestrings and strings (a part from slightly dirty coding)
Avatar of hrvica5

ASKER

Hi, thank you but when I search by widestring i get message error.bmp

Thank you
Wich Delphi version? It seems a unicode bug. I remember there was such a bug in Delphi versions before 2010 (that's the version I've took the test on)
Avatar of hrvica5

ASKER

I have Delphi 2010.

thank you
Strange, same of mine, but I've not any error.
Maybe there's somthing related to the quoted string in your system.
However try this SPeedButtonclick code and report back what happens.
procedure TForm1.SpeedButton1Click(Sender: TObject);
var
  s, sFilter1, sFilter2: string;
begin
  CDS.DisableControls;
  try
    CDS.Filtered := False;
    CDS.FilterOptions := [];
    s := '';
    if Edit1.Text <> '' then
    begin
      sFilter1 := QuotedStr('%'+AnsiupperCase(Edit1.Text)+'%');
      if s <> '' then
        s := s+' AND ';
      s := Format('(UPPER(Field1) LIKE %s or UPPER(Field2) LIKE %s or UPPER(Field3) LIKE %s)', [sFilter1, sFilter1, sFilter1]);
    end;
    if Edit2.Text<>'' then
    begin
      sFilter2 := QuotedStr('%'+AnsiupperCase(Edit2.Text)+'%');
      if s <> '' then
        s := s+' AND ';
      s := s+ Format('(UPPER(Field4) LIKE %s or UPPER(Field5) LIKE %s or UPPER(Field6) LIKE %s)', [sFilter2, sFilter2, sFilter2]);
    end;
    CDS.Filter := s;
    CDS.Filtered := True;
  finally
    CDS.EnableControls;
  end;
end;

Open in new window


Avatar of hrvica5

ASKER

Thank you, but I have same error

Error.jpg
I remember there was a midas.dll bug for TClientDataset   filtering widestrings in the past. My Delphi 2010 build is 14.0.3593.25826 (Delphi 2010 Update 4) that include the same midas dll version 14.0.
Is this the same for you?
Avatar of hrvica5

ASKER

Embarcadero® RAD Studio 2010 Version 14.0.3513.24210

ASKER CERTIFIED SOLUTION
Avatar of Ferruccio Accalai
Ferruccio Accalai
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial