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;