在每个字段的OnValidate下拦截类似这样: procedure TForm_DM.ADODPatient_AgeValidate(Sender: TField); begin if ADODPatient_Age.Value > 200 then raise Exception.Create('年龄不应该这么大。'); end;
在表的onpost或者beforepost事件中进行检查
建表时用UNIQUE对该字段作唯一性检查
procedure TForm1.Button1Click(Sender: TObject); begin if dbgrid1.readonly=false then DBGrid1.readonly:=true; else DBGrid1.readonly:=false; end; 不是吧,只是逻辑问题我认为 这样好吗??跟BUTTON的CAPTION 属性有关系吗?》》
procedure TForm1.Button1Click(Sender: TObject); begin if button1.Caption:='no' then begin DBGrid1.Options := DBGrid.Options + [dgEditing]; button1.Caption:='ok'; end else begin DBGrid1.Options := DBGrid.Options - [dgEditing]; button1.Caption:='no'; end;
procedure TForm_DM.ADODPatient_AgeValidate(Sender: TField);
begin
if ADODPatient_Age.Value > 200 then
raise Exception.Create('年龄不应该这么大。');
end;
begin
if dbgrid1.readonly=false then
DBGrid1.readonly:=true;
else
DBGrid1.readonly:=false;
end;
不是吧,只是逻辑问题我认为
这样好吗??跟BUTTON的CAPTION
属性有关系吗?》》
begin
if button1.Caption:='no' then
begin
DBGrid1.Options := DBGrid.Options + [dgEditing];
button1.Caption:='ok';
end
else
begin
DBGrid1.Options := DBGrid.Options - [dgEditing];
button1.Caption:='no';
end;