I have a TClientDataset which could contain column names with non-ascii characters. It seems that I can not filter on such columns. Here is an example code:

uses
  DB, DBClient;

{$R *.dfm}

procedure TForm34.FormActivate(Sender: TObject);
var
  MyDataset: TClientDataSet;
begin
  MyDataset := TClientDataSet.Create(nil);
  with MyDataset.FieldDefs.AddFieldDef do
  begin
    Name := 'PLACÓWKA';
    DataType := ftString;
  end;
  MyDataset.CreateDataSet;
  MyDataset.Open;
  MyDataset.Append;
  MyDataset.Fields[0].Value := 'Value_1';
  MyDataset.Post;
  MyDataset.Append;
  MyDataset.Fields[0].Value := 'Value_2';
  MyDataset.Post;
  MyDataset.Filter := 'PLACÓWKA LIKE ''%Value_1%''';
  MyDataset.Filtered := True; //Exception here: Field 'PLAC' not found
end;

After settings MyDataset.Filtered := True I am getting exception which says that Field 'PLAC' has not been found.

As far as I can tell the problem lies in method TExprParser.SetExprParams in DBCommon unit which could not properly parse the filter text.

Is there anything I can do with this besides renaming the column?

有帮助吗?

解决方案

For non ansi characters you should use quoted identifiers, each database have their default, in MSSQL it is braces [ ] like: [ PLACÓWKA ].

If you are not using MSSQL you should check your database docs for the appropriate quotes chars.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top