Home > Back-end >  ADOQuery1 ADOQuery2 how to POST the same time?
ADOQuery1 ADOQuery2 how to POST the same time?

Time:10-01

Have a lot of code, in ADOQuery1 ADOQuery2 also has a lot of code,
There is a logical relationship between the data, so when ADOQuery1, POST, ADOQuery2 will POST
For example:
ADOQuery1. POST;
ADOQuery2. POST;

So if ADOQuery1, after POST, host power, then ADOQuery2 cannot POST

So, can you let them at the same time POST

Similar to this: ADOQuery1 and ADOQuery1 POST

Purpose is either all POST, or no,

CodePudding user response:

Using ado transaction
First confirm query1 and query2 adoconnection connection is the same, the code is roughly as follows:
 
ADOConnection1. BeginTrans;//start transaction
Try
//post1
//post2
//post3
ADOConnection1.Com mitTrans;//to commit the transaction
Except,
On E: the Exception do
The begin
ADOConnection1. RollbackTrans;//transaction rollback
end;
end;
  • Related