不科学!
应该有主键吧,在DataSet的OnPost事件中
if pos('主键重复',e.message) then
begin
Action:=arAbort;
showmessage('重复');
end;
实在没有主键 在dataset.OnbeforePos 或者 要检查的Field.OnValidate事件
if DataSet.Locate('fieldname','新插入的值',[]) then
begin
showmessage('重复');
Abort;
end;
我的水平有限只能说自己的笨方法 那就是
你担心的那些会重复的字段的值先存在自己定义的变量当中 然后
用sql语句查询在数据库当中查询这些字段的值是否存在
select COUNT(*) as total from table where ........
如果total的值为0 则是不存在的 就post
否则的话 则利用事务回滚撤销操作