FilterOptions are not supported

I have decided to go from ClientDataSet to ADO but I am having issues when filtering.

This one using ClientataSet works

procedure TMainForm.FilterLogButtonClick(Sender: TObject);
begin
ClientDataSet1.DisableControls;
try
ClientDataSet1.Filtered := False;
ClientDataSet1.FilterOptions := [foCaseInsensitive];
ClientDataSet1.Filter := FilterString + ' LIKE ' + QuotedStr('%'+FilterEdit.Text+'%');
ClientDataSet1.Filtered := True;
finally
ClientDataSet1.EnableControls;
FilterByComboBox.Text := '';
end;
end;


Using ADOTable comes back with the error - 'FilterOptions are not supported'

procedure TMainForm.FilterLogButtonClick(Sender: TObject);
begin
CountryClick.Visible := False;
CountryComboBox2.Visible := False;
ADOTable1.DisableControls;
try
ADOTable1.Filtered := False;
ADOTable1.FilterOptions := [foCaseInsensitive];
ADOTable1.Filter := FilterString + ' LIKE ' + QuotedStr('%'+FilterEdit.Text+'%');
ADOTable1.Filtered := True;
finally
ADOTable1.EnableControls;
FilterByComboBox.Text := '';
end;
end;

Any help would be greatly appreciated.

regards
Steve
regards

Comments

  • Not seen this but then I have not used FilterOptions. My guess would have been that this is not supported by the actual database - but then you say it works for a dataset. Very strange.
    What database are you using?
    What is FilterString in your code?
    Can you use ILIKE instead of LIKE?
    Or you could convert FilterEdit.Text to lower case (Delphi has a LowerCase function in the SysUtils unit) and use LOWER in the filter to convert the database values to lower case.
  • Hi SalmiSoft, thank you for your reply, I am using an .mdb database created with Access, the FilterString I am using is just a TEdit to input the string to look for then it passes the string over to the following procedure;

    procedure TMainForm.FilterLogButtonClick(Sender: TObject);
    begin
    ADOTable1.DisableControls;
    try
    ADOTable1.Filtered := False;
    ADOTable1.FilterOptions := [foCaseInsensitive];
    ADOTable1.Filter := FilterString + ' iLIKE ' + QuotedStr('%'+FilterEdit.Text+'%');
    ADOTable1.Filtered := True;
    finally
    ADOTable1.EnableControls;
    FilterByComboBox.Text := '';
    end;
    end;

    I tried the ILIKE but the same error came back, apart from this it all works well, the reason I have decided to change from ClienDataSet to ADO is that I already use Access and can create a database using it and when a record gets deleted it really has been deleted keeping the file reduced.

    regards
    Steve
  • steve53 wrote:
    I am using an .mdb database created with Access
    That's strange. I just tried a query in Access and it was not case sensitive. Why would mine be different to yours? Not sure. Have you tried the same selection directly in Access? Maybe the case sensitivity is being introduced in Delphi somehow.
    ADOTable1.FilterOptions := [foCaseInsensitive];
    ADOTable1.Filter := FilterString + ' iLIKE ' + QuotedStr('%'+FilterEdit.Text+'%');
    Did you have it like that for your test? Using ILIKE you should not need to set the FilterOptions to ignore case. I suggest you remove that line and re-test.
  • I cant believe it, I took out the following line;

    ADOTable1.FilterOptions := [foCaseInsensitive];

    now all is working perfectly. The line of code was there just as I got it from a search I did on the internet.

    Thanks for your input.

    regards
    Steve
Sign In or Register to comment.