Chapter 9 - Modifications/Corrections/Additions

To ensure that MTS transactions are used effectively with ADO, you must create the instance of the ADO objects within the same context of the MTS transaction. For example, instead of using:

Dim cn As New Connection
...
cn.Open

You would use something similar to the following:

Dim cn As Connection
Dim objContext As ObjectContext

Set objContext = GetObjectContext()

Set cn = objContext.CreateInstance("ADODB.Connection")
...
cn.Open

By doing this, you ensure that the use of SetComplete and SetAbort work for the database activities as well as the ASP component activities. A requirement for all of this to work, though, is that the database engine support MTS transactions.


In example 9-2, the two properties shown with the Recordset Open method, adOpenDynamic and adLockPessimistic generate an error when used together with IIS 4.0, and NT 4.0, SP 4.0. In addition, the Recordset object should be closed. See example code for updated version of example.


In the Further Reading section, replace the following URL:

An overview of using ODBC can be found at http://www.microsoft.com/data/reference/odbc2/sdkodbcoverview_4vcn.htm

With:

An overview of using ODBC can be found at http://msdn.microsoft.com/library/sdkdoc/dasdk/sdko4vcn.htm