试试一下,如不对,贴出你的错误提示var
TimesInt: Integer;
begin
table1.open;
table1.first;
while (not table1.eof) do
begin
 if check.Strings[0]=table1.fieldbyname('Zkzh').asstring then
 begin
 TimesInt:= table1.fieldByname('Time').AsInteger;
 table1.FieldByName('Time').Value:=TimesInt+1;
 Table1.Post;
 Table1.Close; 
 Exit;
 end;
end;
  table1.append;
     table1.FieldByName('Zkzh').Value:=check.strings[0];
     table1.FieldByName('Xm').Value:=check.Strings[1];
     table1.FieldByName('Send').Value:=check.Strings[3];
     table1.FieldByName('receive').Value:=check.Strings[2];
     table1.FieldByName('Time').Value:=1;
     table1.FieldByName('filename').Value:=dir[i];
     table1.Post;
 table1.close;
end;

解决方案 »

  1.   

    为什么不用Locate呢?
    table1.Locate('ZKZH', check.Strings[0], []);
      

  2.   

    var 
    ishaveid:boolean;//是否有zkzh为id变量值的记录begin
    ishaveid:=false;//没有table1.open;
    while (not table1.eof) do
    begin
     if check.Strings[0]=table1.fieldbyname('Zkzh').asstring then
     begin
     ishaveid:=true;//有该id
     break;
     end;
    end;if ishaveid then//有则改
    begin
     table1.edit;
     table1.FieldByName('Time').Value:=table1.fieldByname('Time').AsInteger+1;
     table1.post;
    end
    else
    begin//无则加
         table1.append;
         table1.FieldByName('Zkzh').Value:=check.strings[0];
         table1.FieldByName('Xm').Value:=check.Strings[1];
         table1.FieldByName('Send').Value:=check.Strings[3];
         table1.FieldByName('receive').Value:=check.Strings[2];
         table1.FieldByName('Time').Value:=1;
         table1.FieldByName('filename').Value:=dir[i];
         table1.Post;
    end;
    table1.close;
    end;
    你的代码错在追加要用append,修改要用edit.是个低级错误。
      

  3.   

    错在好几个地方,这样吧我还是拷贝你的程序然后修改如下:
    table1.open;
    table1.first;
    while (not table1.eof) do
    begin
     if check.Strings[0]=table1.fieldbyname('Zkzh').asstring then
     begin
      if not (table1.state in [dsedit,dsInsert]) then table1.edit;
     table1.FieldByName('Time').Value:=table1.fieldByname('Time').AsInteger+1;
      table1.post;
     break; end
     else
     table1.next;
     end;
     if table1.eof then
         begin
          table1.append;
         table1.FieldByName('Zkzh').Value:=check.strings[0];
         table1.FieldByName('Xm').Value:=check.Strings[1];
         table1.FieldByName('Send').Value:=check.Strings[3];
         table1.FieldByName('receive').Value:=check.Strings[2];
         table1.FieldByName('Time').Value:=1;
         table1.FieldByName('filename').Value:=dir[i];
         table1.Post;
         end;
     table1.close;
      

  4.   

    dongxsoft大哥,有错误
    table1 cannot edit?
      

  5.   

    支持 ocean617(海洋) 的寫法;程序可讀性也比較好
    其他幾位也都指出了你的錯誤