Forum
× Components and Libraries for Database Development, discussions, problems and suggestions

Question Filtering dataset not working CT6.8 - Firebird 3

  • Jose Ceravolo
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
3 months 3 days ago #13677 by Jose Ceravolo
Hi All,

I am new to CT and I have a procedure that sets up a filter in a dataset.
It works in Delphi, but I can't get to work with CT.
The filter is UPPER(NAME) like '%C%'.
That should return any NAME that contains a C character in it.

Thanks in advance,

Jose.

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Away
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
3 months 2 days ago #13678 by Sternas Stefanos
Replied by Sternas Stefanos on topic Filtering dataset not working CT6.8 - Firebird 3
Thanks Sir
First of all we don't use Delphi. :)

Please give us more info:
Your OS, a code sample.
etc

PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

  • Jose Ceravolo
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
3 months 2 days ago #13680 by Jose Ceravolo
Replied by Jose Ceravolo on topic Filtering dataset not working CT6.8 - Firebird 3
Hello Sternas,

I am using Windows 10.

Here's the code:


procedure TfrmDataBrowser.btApplyClick(Sender: TObject);
begin
if dsData.DataSet.FieldByName(lcFilter) is TStringField then
begin
dsData.DataSet.Filter := 'UPPER(' + lcFilter + ') like ' + quotedstr('%' + uppercase(edtSearch.Text) + '%');
end
else dsData.DataSet.Filter := lcFilter + ' = ' + edtSearch.Text;
dsData.DataSet.Filtered := true;
edtSearch.SelectAll;
edtSearch.SetFocus;
end;

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Away
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
3 months 2 days ago - 3 months 2 days ago #13681 by Sternas Stefanos
Replied by Sternas Stefanos on topic Filtering dataset not working CT6.8 - Firebird 3
Try this
procedure TfrmDataBrowser.btApplyClick(Sender: TObject);
begin
dsData.DataSet.Filtered := true;
if dsData.DataSet.FieldByName(lcFilter) is TStringField then
begin
dsData.DataSet.Filter := 'UPPER(' + lcFilter + ') like ' + quotedstr('%' + uppercase(edtSearch.Text) + '%');
end
else dsData.DataSet.Filter := lcFilter + ' = ' + edtSearch.Text;
edtSearch.SelectAll;
edtSearch.SetFocus;
end;

PilotLogic Architect and Core Programmer
Last edit: 3 months 2 days ago by Sternas Stefanos.

Please Log in or Create an account to join the conversation.

  • Jose Ceravolo
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
3 months 2 days ago #13683 by Jose Ceravolo
Replied by Jose Ceravolo on topic Filtering dataset not working CT6.8 - Firebird 3
It's the same, it does not return any records.
It still works for integer fields.

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Away
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
3 months 2 days ago - 3 months 2 days ago #13684 by Sternas Stefanos
Replied by Sternas Stefanos on topic Filtering dataset not working CT6.8 - Firebird 3
My suggestion is
to attach here a test project
procedure TfrmDataBrowser.btApplyClick(Sender: TObject);
begin
dsData.DataSet.Filtered := true;
dsData.DataSet.Refresh;

if dsData.DataSet.FieldByName(lcFilter) is TStringField then
begin
dsData.DataSet.Filter := 'UPPER(' + lcFilter + ') like ' + quotedstr('%' + uppercase(edtSearch.Text) + '%');
end
else dsData.DataSet.Filter := lcFilter + ' = ' + edtSearch.Text;
edtSearch.SelectAll;
edtSearch.SetFocus;
end;

PilotLogic Architect and Core Programmer
Last edit: 3 months 2 days ago by Sternas Stefanos.

Please Log in or Create an account to join the conversation.

  • Jose Ceravolo
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
3 months 2 days ago #13685 by Jose Ceravolo
Replied by Jose Ceravolo on topic Filtering dataset not working CT6.8 - Firebird 3
Ok, I created a working test project.
The idea is to click on the title of the grid to be able to search that field.
It works with the integer field.

File Attachment:

File Name: TestProject.zip
File Size:671 KB
Attachments:

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Away
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
3 months 2 days ago #13688 by Sternas Stefanos
Replied by Sternas Stefanos on topic Filtering dataset not working CT6.8 - Firebird 3
For which Firebird ver is your NEWDATABASE.FDB ?

PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

  • Jose Ceravolo
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
3 months 2 days ago #13689 by Jose Ceravolo
Replied by Jose Ceravolo on topic Filtering dataset not working CT6.8 - Firebird 3
Firebird 3

Please Log in or Create an account to join the conversation.

  • Jose Ceravolo
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
3 months 1 day ago #13692 by Jose Ceravolo
Replied by Jose Ceravolo on topic Filtering dataset not working CT6.8 - Firebird 3
I got it to work by replacing the % for *.
I wonder why that is. The % should work with Firebird.
Anyway, it's working, but it should not be like that.

Thanks,

Jose.

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Away
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
3 months 1 day ago #13693 by Sternas Stefanos
Replied by Sternas Stefanos on topic Filtering dataset not working CT6.8 - Firebird 3
Thanks Sir
have fun

PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.