Welcome, Guest
Username: Password: Remember me
Components and Libraries for Database Development, discussions, problems and suggestions
  • Page:
  • 1

TOPIC:

Filtering dataset not working CT6.8 - Firebird 3 5 years 3 months ago #13677

  • Jose Ceravolo
  • Jose Ceravolo's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 25
  • Thank you received: 0
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.

Filtering dataset not working CT6.8 - Firebird 3 5 years 3 months ago #13678

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4538
  • Thank you received: 1116
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.

Filtering dataset not working CT6.8 - Firebird 3 5 years 3 months ago #13680

  • Jose Ceravolo
  • Jose Ceravolo's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 25
  • Thank you received: 0
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.

Filtering dataset not working CT6.8 - Firebird 3 5 years 3 months ago #13681

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4538
  • Thank you received: 1116
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

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

Last edit: by Sternas Stefanos.

Filtering dataset not working CT6.8 - Firebird 3 5 years 3 months ago #13683

  • Jose Ceravolo
  • Jose Ceravolo's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 25
  • Thank you received: 0
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.

Filtering dataset not working CT6.8 - Firebird 3 5 years 3 months ago #13684

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4538
  • Thank you received: 1116
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

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

Last edit: by Sternas Stefanos.

Filtering dataset not working CT6.8 - Firebird 3 5 years 3 months ago #13685

  • Jose Ceravolo
  • Jose Ceravolo's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 25
  • Thank you received: 0
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.

Filtering dataset not working CT6.8 - Firebird 3 5 years 3 months ago #13688

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4538
  • Thank you received: 1116
For which Firebird ver is your NEWDATABASE.FDB ?
PilotLogic Architect and Core Programmer

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

Filtering dataset not working CT6.8 - Firebird 3 5 years 3 months ago #13689

  • Jose Ceravolo
  • Jose Ceravolo's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 25
  • Thank you received: 0
Firebird 3

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

Filtering dataset not working CT6.8 - Firebird 3 5 years 3 months ago #13692

  • Jose Ceravolo
  • Jose Ceravolo's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 25
  • Thank you received: 0
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.

Filtering dataset not working CT6.8 - Firebird 3 5 years 3 months ago #13693

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4538
  • Thank you received: 1116
Thanks Sir
have fun
PilotLogic Architect and Core Programmer

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

  • Page:
  • 1