Begin Tran open disconnected recordset - reconnect - rollback/comm

Begin Tran open disconnected recordset - reconnect - rollback/comm

Post by SmFtaW » Thu, 28 Feb 2008 05:58:03


Is is possible to commit or rollback under the following circumstances using
ADO?

1. Begin a Tran on a database
2. Open a recordset and disconnect it
3. Perform multiple operations on the disconnected recordset
4. Reconnect and updatebatch on the recordset with adMarshallAll (default)
5. Filter (ModifiedRS.Filter = adFilterConflictingRecords)
6. When ModifiedRS.recordcount>0
6a ROLLBACK initial Tran from step 1.
7. Whne ModifiedRS.recordcount=0
7a COMMIT initial Tran from step 2.

Given above sequence, if Rollback or Commit is completed
A) Will TRANSACTION effect the updatebatch condition given that the record
was opened after the Begin Tran?
OR
B) Will the fact that the recordset is disconnected mean that the
commit/rollback tran will not effect the records from that batch?
 
 
 

Begin Tran open disconnected recordset - reconnect - rollback/comm

Post by Stephen Ho » Thu, 28 Feb 2008 06:31:57

> Is is possible to commit or rollback under the following circumstances

Must be. We do it here.


Yes but at this stage here, a transaction is associated with a particular
ADO Connection (I am assuming that you are using ADO's transactions)
Therefore in step 2, the Recordset may be disconnected, but I assume you
have kept the Connection alive that the Transaction in step 1 is associated
with.
And if you kept that Connection alive then your "reconnect" amounts to
reintroducing your Recordset to the same live Connection.


But steps 5, 6, 7 are not necessary.
If a COM Exception is thrown => do a Rollback
If a COM Exception is not thrown => do a Commit


You mean the other way round.
There is a pending transaction when UpdateBatch is called => whatever
happens in UpdateBatch in terms of INSERTs/UPDATEs/DELETEs will be in the
transaction


Neither. It depends entirely on whether yo uare using the same Connection
object that has the transaction or not.
If it is the same object => Recordset is covered in the Transaction
If it is a different object => Recordset is not covered in the Transaction

Stephen Howe