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;
begin
showmessage('这个编号已经存');
Edit1.SetFocus;
Exit;
end;
else if DataModule1.ADOTable1.locate('DESC',edit2.text,[lopartialkey]) then
begin
showmessage('这个名称已经存');
Edit2.SetFocus;
Exit;
end;
THE application is using arguments that of the wrong type,are out of
acceptable range,or are in conflict with one another.
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;