没有活动的事务,特急,谢谢(58分)

  • 主题发起人 主题发起人 gongfs
  • 开始时间 开始时间
G

gongfs

Unregistered / Unconfirmed
GUEST, unregistred user!
各位大侠:<br>我用下列语句,写程序数据库,会偶尔提示,没有活动的事务,请指点:特急,谢谢<br>datamodule2.ADOConnection1.BeginTrans;<br>&nbsp;try<br>语句片段<br>&nbsp; &nbsp;datamodule2.ADOConnection1.CommitTrans;//执行事务<br>&nbsp;except <br>&nbsp; &nbsp; &nbsp; &nbsp; on &nbsp; E: &nbsp; Exception &nbsp; do <br>&nbsp; &nbsp; &nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; datamodule2.ADOConnection1.RollbackTrans; &nbsp; //事务异常则回滚<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ShowMessage(E.Message);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit; <br>&nbsp; &nbsp; &nbsp; &nbsp; end; <br>&nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; &nbsp; &nbsp;// 事务结束
 
可能是ADOConnection有时候没有连上,具体你自己要试试看才行。
 
if datamodule2.ADOConnection1.inTransaction then datamodule2.ADOConnection1.RollbackTrans;
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
928
SUNSTONE的Delphi笔记
S
后退
顶部