你先用
query1.local查找,根据返回值来处理。

解决方案 »

  1.   

    可以使用Ttable主件的Locate方法,它返回一个布尔值,具体可见联机帮助!
      

  2.   

    select count(*) as quan from table1 where fld = 'ddd' group by fld
      

  3.   

    在数据集的BeforePost事件中加
    With Query1 do begin
         Close;
         SQL.Clear;
         SQL.Add('Select Count(*) as Count From Table Where KeyField=:KeyField');
         ParamByName('KeyField').asString:=varKeyFiled;
         Open;
         if Count>0 then ShowMessage('数据重复');
         Close;
    end;
      

  4.   

    或者用Ado的Locate方法:
    AdoQuery.Locate("Field1","Value1");支持多字段。
      

  5.   

    agree wolfAone(¤一步一步网上爬¤) 
    up
      

  6.   

    这就是primary key 的作用了!!
    检查有没有重复的primary key,有就是重复,没有就insert。呵呵!!
      

  7.   

    如果是单值比较,可用query1.local,多值比较只能用select了,可参考johnsonrao(johnson)的做法,但最好建议用另外一个新Query作判断,因为用同一个query,dbedit等相关数据会被改变!