它的数据库异常类都是在Edatabaseerror中处理的。用try只能截获到Edtabaseerror,如果你需要捕捉“数据库没有处于打开状态的异常和不在edit模式的异常”,我想:if table1.active=false then databaseerror('数据集没有打开',table1); if (table1.state<>dsedit)or(table1.state<>dsinsert) then databaseerror('数据集没有处于编辑或插入状态',table1); table1.post;好像没有什么意义
因为delphi内部就是这样处理的,只不过显示的异常信息是英文罢了 你只需使用 try ...except on e:Edatabaseerror do showmessage(e.message); end; 能够截获所有的Edatabaseerror的异常
databaseerror('数据集没有打开',table1);
if (table1.state<>dsedit)or(table1.state<>dsinsert) then
databaseerror('数据集没有处于编辑或插入状态',table1);
table1.post;好像没有什么意义
你只需使用
try
...except
on e:Edatabaseerror do
showmessage(e.message);
end;
能够截获所有的Edatabaseerror的异常
语句;
except
on 异常类 do
处理;
else
处理;
end;