var
  codeStr: String;
  i:integer;
Begin  if (Edit1.Text<>'') then
  begin
  i:=0;  with WMG_DM.cha_adoquery do
      begin
         close;
         sql.Clear;
         sql.Add('SELECT cname FROM chaee');
         open;         with WMG_DM.cha_adoquery do
         begin
           first;
           while not Eof do
           begin
            if pos(trim(edit5.text),fieldbyname('cname').AsString)>0 then
    {想实现表chaee中字段cname的每个记录与trim(edit5.text)进行比较,如果包含trim(edit5.text)字符串,则i+1}
             begin
             //>0为包含子串,=0为不包含子串
                  i:=i+1;
               edit7.text:=inttostr(i);
                next;
             end;
               if pos(trim(edit5.text),fieldbyname('cname').AsString)=0 then
             begin
             //>0为包含子串,=0为不包含子串
                showmessage('字段cname中不包含edit5.text所显示的字符串,请核查。');
                close;
             end;
         end;
end;
end;
end;我写的貌似有问题
数据集里面逐个比较字段cname(字符串型)是否包含字符串edit5.text内容,是不是不能这么写??
if pos(trim(edit5.text),fieldbyname('cname').AsString)>0 then
请高手们给改改,谢谢了StringDelphi