Delphi Base

WindSon

导航

Delphi 模糊查询和字段查询

procedure TFrmain.scGPEdit1Change(Sender: TObject);
var
  ASql, AKey: string;              //模糊查询和字段查询
const
  vsql1: string = 'select * from delphi where Title like ';
  vsql2: string = 'select * from delphi';
begin
  AKey := Trim(scGPEdit1.Text); //获取关键词
  if scGPEdit1.Text = '' then
    ASql := vsql2
  else
    ASql := vsql1 + QuotedStr('%' + AKey + '%');
  with dm.FDQuery1 do   //开始查询
  begin
    Close;
    SQL.Text := ASql;
    Open;
  end;
end;

 

posted on 2020-04-05 22:11  windsonvip  阅读(534)  评论(0编辑  收藏  举报