Partial Search In Table(BDE)

孤街浪徒 提交于 2020-01-03 04:14:04

问题


I made a database with paradox 7. The usual search I do is a syntax like this:

Table.Filter := 'Country=' + QuotedStr(Edit.Text);

This returns rows those country field is same as the entered text in edit. when I want to search for countries are beginning by "L" i use this syntax:

Table.Filter := 'Country=' + QuotedStr(Edit.Text + '*');

But how can I search for fields those are finished with "L"? this syntax does not work:

Table.Filter := 'Country=' + QuotedStr('*' + Edit.Text  );

Thanks.


回答1:


You can use the OnFilterRecord event to carry out a customized filtering. With your example, maybe sth. like this:

procedure TForm1.Table1FilterRecord(DataSet: TDataSet; var Accept: Boolean);
var
  s: string;
begin
  Accept := False;
  if not DataSet.FieldByName('Country').IsNull then begin
    s := DataSet.FieldByName('Country').AsString;
    Accept := Copy(s, Length(s), 1) = 'L';
  end;
end;


来源:https://stackoverflow.com/questions/3989982/partial-search-in-tablebde

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!