用ADO技术?数据库ORACLE,Delphi6

解决方案 »

  1.   

    Select *
    From test
    Where 主键=新输入记录的主键
    然后判断RecordCount是否大于0
      

  2.   

    在append之前,先qryTmp.Clone(yourQry,ltBatchOptimistic);然後,在yourqry的beforepost事件裡面,qryTmp.locate('yourfieldname',value,[])if find ,then showmessage('重復')else showmessage('哈哈,讓你得逞了!')
      

  3.   

    用Try Except把错误显示出来就知道主键是否重复了
      

  4.   

    你要不就写SQL ,要不就用 Try Except 捕捉错误SQL 可以如下写法,如果没有重复的主键则Insert:
    if not exists(select MainID from mainTable where MainID=@mainID) Insert Into MainTABLE (mainID,...)values(@mainID,...)
      

  5.   

    suton(suton) 的方法也是很常用的方法,推荐在前台程序内写而不通过数据库反馈
      

  6.   

    query1.close;
    query1.sql.clear;
    query1.sql.add('select * from table1 where id=:id1');
    query1.parambyname('id').asstring:=edit1.text;
    query1.open;
    if query1.recordcount>0 then
    begin
      showmessage('数据库中有重复记录');
      abort;
    end;