if  DataModule1.ADOTable1.Locate('LIBNO',edit1.text,[lopartialkey]) then
    begin
      showmessage('这个编号已经存');
      Edit1.SetFocus;
      Exit;
    end;
else if DataModule1.ADOTable1.locate('DESC',edit2.text,[lopartialkey]) then
    begin
      showmessage('这个名称已经存');
      Edit2.SetFocus;
      Exit;
    end;

解决方案 »

  1.   

    还是不行,还是那里出错,出错提示为:
    THE application is using arguments that of the wrong type,are out of 
    acceptable range,or are in conflict with one another.
      

  2.   

    相信我没错的,建议你这样编程,把不能重复的字段在数据库里约束为“无重复”,然后在
    ADOTable1.onPostError下类似这样写:
    procedure TForm_DM.ADOTable1.PostError(DataSet: TDataSet; E: EDatabaseError;
      var Action: TDataAction);
    var
      adoErrors: Errors;
      adoError: Error;
      iCount: Integer;
    begin
      adoErrors := ADOC_Holter.Errors;
      for iCount := 0 to adoErrors.Count - 1 do
      begin
        adoError := adoErrors.Item[iCount];
        if (adoError.NativeError = -105121349) then
          raise exception.Create('说明:为了便于管理,字段“编号”或“姓名”的值是不允许重复出现的。请输入其他的值。');
      end;
    end;
    如果非要这样写的化那么让DESC改名为DESC1(DESCd在中ado中有用,为降序字)试试:
    if  DataModule1.ADOTable1.Locate('LIBNO',edit1.text,[lopartialkey]) then
        begin
         raise exception.Create('这个编号已经存');
          
        end;
    if DataModule1.ADOTable1.locate('DESC'//,edit2.text,[lopartialkey]) then
        begin
          raise exception.Create(('这个名称已经存');
        end;