procedure TfrmRQZLGL.btnDelete_ZLClick(Sender: TObject);
var
Str1,Str2:string;
begin
if Application.MessageBox('正在删除信息,是否继续?', '提示信息', MB_YESNO +
MB_ICONQUESTION) = IDYES then
begin
Str1 := Format('delete from RQ_ZLZB where BillNo = %s',[qry_ZLZB.FieldByName('BillNo').AsString]);
Str2 := Format('delete from RQ_ZLMXB where BillNo = %s',[qry_ZLZB.FieldByName('BillNo').AsString]);
if not DMMain.conMain.InTransaction then DMMain.conMain.BeginTrans;
try
DMMain.ExecSQLA(Str1);
DMMain.ExecSQLA(Str2);
except
if DMMain.conMain.InTransaction then DMMain.conMain.RollbackTrans;
end;
DMMain.conMain.CommitTrans;
end;
end;有以上代码,用来删除主表和从表的关联数据,但是 报错了,说 ‘没有活动事务’,望高人指点!
解决方案 »
- Delphi写DLL给Asp.net(C#)用
- 我快吐血了,到底怎么刷新桌面?
- 用过Quick Report的请进来,没用过也来捧捧场
- 大家帮我填一下这段程序~~~~~
- 怎样得到MEMO中回车换行符的位置?
- 如何批量增加纪录
- 请问有谁知道ThemeEngine 3.1.5(实现XP效果的控件)在DELPHI7下怎么安装?
- 高手们,就就哦把
- Delphi操作paradox表或者VFP表时,怎么实现VFP中的select * from table1 into cursor temptable 的功能。
- 谁有Big5码与GB码互相转换的控件啊?
- 求助,如何将excel表中的数据导入access已存在的某个表中
- oralce字段blob类型,怎样处理word文档?显示、保存
才能 CommitTrans一般这样DMMain.conMain.BeginTrans
try
DMMain.ExecSQLA(Str1);
DMMain.ExecSQLA(Str2);
DMMain.conMain.CommitTrans;
except
DMMain.conMain.RollbackTrans;
end;
try
DMMain.ExecSQLA(Str1);
DMMain.ExecSQLA(Str2);
Except
if DMMain.conMain.InTransaction then DMMain.conMain.RollbackTrans;
end;
DMMain.conMain.CommitTrans;
我是在 Except 里面写的 RollBackTrans 最后CommitTrans的