PDA

Click to See Complete Forum and Search --> : MTS: Microsoft Transaction Server / VB


Benny
Oct 4th, 2000, 02:51 PM
I have ASP code which includes a function that will call a component in an MTS package via Server.CreateObject. The component in the MTS package has the transaction attributes set to "Does not support transactions". Would you still need to use the declaring and setting of the object context within this component(dim objctx as objectcontext and set objctx=GetobjectContext) if not supporting transactions? I didn't think so since there aren't any transactions or need to use SetAbort or SetComplete but I could be wrong.

Now, if I have a second module that uses the statement:
Dim loADSI As New Module1.Component to access the above component in the MTS package: Would it be necessary for both of them to be in the MTS package? Would it at least be necessary to change the 'As New' code in this second module to using 'CreateInstance'?

I would appreciate any information anyone can provide...
Thanks!

Clunietp
Oct 5th, 2000, 10:20 PM
Hi Benny

1st Q:
Always use Setcomplete/Setabort, even if you don't currently use transactions. This allows the MTS wrapper to efficiently deactivate your objects and pool the threads. If you later want to use transactions, you won't have to modify any code. If you want to avoid a recompile later on and your object modifies data in a database, set it to USES TRANSACTIONS. This will allow it to use a transaction if one already exists, but if a transaction does not exist, it will not create one.


2nd Q:
Use early binding along with CreateObject.
example
dim objMyObject as ProjectDLL.MyClass
set objMyObject = ObjectContext.CreateInstance("ProjectDLL.MyClass")

This will give you better performance than late binding, but if the component you are calling uses transactions, it must be in its own context managed by MTS. CreateInstance facilitates this.

Hope this helps

Tom