Using LIKE statement for filtering

后端 未结 6 1758
南方客
南方客 2021-01-05 06:44

Im using this code to filter my table:

Table.Filtered := False;
Table.Filter := \'[\' + Field_Search + \'] LIKE \'\'%\' + Edit_Search.Text + \'%\'\'\';
Tabl         


        
6条回答
  •  一整个雨季
    2021-01-05 07:23

    you should use this :

       DataModule.Table.Filtered := False;
       DataModule.Table.Filter := 'Field_Name' + ' LIKE ' + QuotedStr(Edt_SearchByCode.Text +'%');
       DataModule.Table.Filtered := True;
    

    and will work like a Magic and no use of TQuery any more .... and if you want Matching does not take case-sensitivity into account. you should use this code instead:

       DataModule.Table.Filtered := False;
       DataModule.Table.FilterOptions := [foCaseInsensitive];
       DataModule.Table.Filter := 'Field_Name' + ' LIKE ' + QuotedStr(Edt_SearchByCode.Text +'%');
       DataModule.Table.Filtered := True;
    

提交回复
热议问题