
VB6/COM+ multiple database transaction errors not trapped soon enough
Hello again,
I now realize that distributed COM+ transactions are commited at Setcomplete
time by design and that its my job, as an application developer, to call
Setcomplete when it can be trapped by my application. My application uses
Active Server Pages to call root COM+ objects (VB6 classes) which, in turn
call secondary COM+ objects (also VB6 classes). Since the secondary object
executes the embedded SQL command, there is no need to include the caller in
the transaction. The caller can then trap the error gracefully when the
secondary object Setcomplete fails.
Specifically, I resolved the problem described below by setting the
MTSTransactionMode property of my called COM+ object to
"RequiresTransaction" and execute mobjContext.SetComplete therein while
setting the root COM+ object's property to "NoTransaction". The only fly in
the oinment is that the error message returned by the system is a timeout
error rather than an error reported by the trigger as when the same
transaction is executed using the SQL Server query analyzer. I suppose
there is a way to peel through the Conn.errors stack and find it.
Quote:
> Hello,
> I am using VB6 SP5 over Windows 2K SP2 to develop a class library that
runs
> as a library component of IIS. My DLL updates three SQL Server 2K
databases
> via ADO. I initialize the connection object provider to "sqloledb".
> Sometimes, a single embedded SQL transaction (insert or update) will
change
> multiple SQL Server databases via SQL Server triggers. In such cases, I
> understand that I need to set the appropriate VB class MTSTransactionMode
> property to RequiresNewTransaction in the root COM+ object and
> RequiresTranscation in subordinate objects so that the multiple-database
> update will be managed. But, it doesn't trap the errors until the root
> object executes mobjContext.SetComplete and the "On Error..." condition
that
> would report the failure in a user friendly manner passes out of scope.
> Does anyone know how to get VB6/COM+ to trap multiple-database transaction
> errors as when the embedded SQL command is executed?