Since VB and .NET will use different SQL connections (and there is no way to make ADO and ADO.NET the same connection), your only option is to enlist the DTC (Distributed Transaction Coordinator). DTC will coordinate two independent transactions so that they complete or collapse together.
From .NET, EnterpriseServices manages COM + features such as DTC. In .NET 2.0 and forward, you can use the System.Transactions namespace, which makes things a little nicer. I think something like this should work (unverified code):
void SomeMethod() { EnterpriseServicesInteropOption e = EnterpriseServicesInteropOption.Full; using (TransactionScope s = new TransactionScope(e)) { MyComPlusClass o = new MyComPlusClass(); o.SomeTransactionalMethod(); } }
I am not familiar enough with this to give you more advice at the moment.
On the COM + side, your object must be configured to use (most likely "required") a distributed transaction. You can do this from COM + Explorer by going to your Properties object, selecting the Transaction tab, and clicking Mandatory. I donβt remember if you can do this from code; VB6 was created before the release of COM +, so it does not fully support everything that COM + does (its transactional support is for the predecessor of COM +, called MS Transaction Server).
If everything works correctly, your COM + object must be credited to the existing Context created by your .NET code.
You can use the "Distributed Transaction Coordinator \ Transaction List" node in "Component Services" to check and view the distributed transaction that is created during the call.
Keep in mind that you do not see changes from the COM + component reflected in the data requests from the .NET side until the transaction is completed! In fact, you can come to a standstill! Remember that DTC will verify that two transactions are conjugated, but they are still separate database transactions.
source share