Tmp_query.Connection.BeginTrans; try Excutesql('delete from person_archives where personnel_id=''' + adoquery1.fieldbyname('personnel_id').asstring + ''''); Tmp_query.Connection.CommitTrans; Tmp_query.free; except Tmp_query.Connection.RollbackTrans; Tmp_query.Free; exit; end;
procedure TForm1.tuiding; begin dm.adoconnection1.BeginTrans; try with dm.ADOQuery2 do begin Close; SQL.Clear; SQL.Add('select user_id from users where mobile_phone='''+s+'''') ; open; end; user:= dm.ADOQuery2.Fields[0].AsString; with dm.ADOQuery3 do begin Close; SQL.Clear; SQL.Add('delete from user_yc_orders where user_id='''+user+'''') ; execsql; end; dm.ADOQuery5.Close; dm.ADOQuery5.sql.clear; dm.ADOQuery5.SQL.add('insert into t_smssent(f_mobile,f_msgcontent,f_status) values('''+s+''',''退定包月成功!'',0)'); dm.ADOQuery5.ExecSQL; dm.ADOQuery4.Close; dm.ADOQuery4.sql.clear; dm.ADOQuery4.SQL.add('update t_smsreceived set f_status=1 where f_id='+sss+''); dm.ADOQuery4.ExecSQL; dm.adoconnection1.CommitTrans; except dm.adoconnection1.RollbackTrans; end; end;
try
Excutesql('delete from person_archives where personnel_id='''
+ adoquery1.fieldbyname('personnel_id').asstring + '''');
Tmp_query.Connection.CommitTrans;
Tmp_query.free;
except
Tmp_query.Connection.RollbackTrans;
Tmp_query.Free;
exit;
end;
begin
dm.adoconnection1.BeginTrans;
try
with dm.ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('select user_id from users where mobile_phone='''+s+'''') ;
open;
end;
user:= dm.ADOQuery2.Fields[0].AsString;
with dm.ADOQuery3 do
begin
Close;
SQL.Clear;
SQL.Add('delete from user_yc_orders where user_id='''+user+'''') ;
execsql;
end;
dm.ADOQuery5.Close;
dm.ADOQuery5.sql.clear;
dm.ADOQuery5.SQL.add('insert into t_smssent(f_mobile,f_msgcontent,f_status) values('''+s+''',''退定包月成功!'',0)');
dm.ADOQuery5.ExecSQL;
dm.ADOQuery4.Close;
dm.ADOQuery4.sql.clear;
dm.ADOQuery4.SQL.add('update t_smsreceived set f_status=1 where f_id='+sss+'');
dm.ADOQuery4.ExecSQL;
dm.adoconnection1.CommitTrans;
except
dm.adoconnection1.RollbackTrans;
end;
end;
AdoConnection.BeginTrans;//开始一个事务
try
{你具体要处理的各个事务操作
}
AdoConnection.CommitTrans;//提交事务
except
AdoConnection.RollbackTrans;//异常事务回滚,取消所有事务
en;
procedure TButton1.Cilck(Sender: TObject);
begin
AdoConnection.BeginTrans;//开始一个事务
end;procedure TButton.Cilck(Sender: TObject);
begin
AdoConnection.RollbackTrans;//异常事务回滚,取消所有事务
end;但是我不知道这样有什么意义!