Visual Basic Concepts
The BeginTrans, CommitTrans, and RollbackTrans methods are all supported on the rdoEnvironment object to begin, commit, or roll back ODBC distributed transactions. These methods are implemented using the Distributed Transaction Coordinator (DTC) on systems that support this technology. At this time, only Microsoft SQL Server 6.5 supports DTC. All connections in the rdoConnections collection for the rdoEnvironment object participate in the distributed transaction.
This new feature of Microsoft SQL Server coordinates transactions across a network of Microsoft Windows NT– and Microsoft Windows 95/98–based systems. With MS DTC, SQL Server can:
You can also use MS DTC by using the Distributed Transaction Coordinator command from the Server menu.
Microsoft Distributed Transaction Coordinator addresses the challenges of processing transactions over a distributed set of software components that exist on a system of networked computers. MS DTC is fully integrated with Microsoft SQL Server 6.5 and provides a transaction manager in SQL Enterprise Manager at each computer that manages distributed transactions.
If the DTC is not available, or if the current ODBC driver cannot handle a distributed transaction, these methods force RDO to perform a serialized transaction across all connections in the rdoConnections collection. But these transactions are not atomic — that is, operations executed against one rdoConnection could complete, but those against another might not. In this case, the committed operations are not rolled back. Because of this, their success or failure is not interdependent.
Because the rdoEnvironment object determines transaction scope in your application, committing an rdoEnvironment transaction commits all pending transactions on all open rdoConnection databases (which are opened on that rdoEnvironment object and their corresponding open rdoResultset objects). This does not imply a two-phase commit operation. It simply means that individual rdoConnection objects are instructed to commit any pending transactions — one at a time.
Note The ODBC transaction model does not support nested transactions. That is, you cannot execute a second BeginTrans method before the previous transaction is either committed or rolled back. However, if your ODBC data source supports it, you can use SQL statements to execute nested transactions. This is supported by all Microsoft SQL Server systems.
When you use ODBC transactions, transactions do not span connections: Transactions begun and committed on one connection do not affect transactions pending on other connections, even if both connections are made to the same server and database.
The rdoEnvironment object fires an event whenever a transaction operation has completed. These events can be used to synchronize other processes with the transaction state. Basically, the BeginTrans, CommitTrans, and RollbackTrans event fire after the corresponding method has fired.