另一个办法:
用adoquery,属性locktype 设为ltBatchOptimistic
再看看下面的代码。OK!
procedure TForm1.Button1Click(Sender: TObject);
var
s: String;
begin
with q1do
begin
DisableControls;
First;
While not eofdo
begin
if s=Fieldbyname('部门').AsString then
begin
Edit;
Fieldbyname('部门').Value:='';
Post;
end
else
s:=Fieldbyname('部门').AsString;
Next;
end;
enableControls;
end;