hrvica5
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
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
What's the matter really? Because testing your example works fine both for widestrings and strings (a part from slightly dirty coding)
ASKER
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)
ASKER
I have Delphi 2010.
thank you
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.
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;
ASKER
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?
Is this the same for you?
ASKER
Embarcadero® RAD Studio 2010 Version 14.0.3513.24210
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.