运行时提错
出错提示为:project project1.exe raised cexeption class edbengineError whit
message'Key violation,',process stopped .Use step or Run to continue.
经常出现这种情况,但不知道是什么意思,望高手解答。
procedure TForm1.Button1Click(Sender: TObject);
begin
table1.active:=true;
table1.insert;
table1.fieldbyname('bm').asstring:=edit1.text;
table1.fieldbyname('xm').asstring:=edit2.text;
table1.fieldbyname('rq').asdatetime:=data.date;
if edit1.text='' then
begin
showmessage('记录为空,不能输入');
edit1.setfocus;
end;
if edit1.text='' then
begin
showmessage('记录为空,不能输入');
edit1.setfocus;
end ///执行到这里的时候就应该停止下面语句了。
else //用它来做选择
begin
table1.post;
edit1.text:='';
edit2.text:='';
showmessage('添加成功!!');
edit1.setfocus;
end
end;
lnboy兄,我照你的输入, 当edit.text为空时可以出现提示并跳到edit1.text 处.重新
输入编码(BM)时出错.出错提示为:project project1.exe raised cexeption class
edbengineError whit message'Key violation,',process stopped .Use step or Run
to continue.确定后跳出main.pas大标压在table1.fieldbyname('bm').asstring:=edit1.text;
procedure TForm1.Button1Click(Sender: TObject);
begin
if edit1.text='' then
begin
showmessage('记录为空,不能输入');
edit1.setfocus;
end
else
begin
table1.active:=true;
table1.insert;
table1.fieldbyname('bm').asstring:=edit1.text;
table1.fieldbyname('xm').asstring:=edit2.text;
table1.fieldbyname('rq').asdatetime:=data.date;
table1.post;
edit1.text:='';
edit2.text:='';
showmessage('添加成功!!');
edit1.setfocus;
end;
end;