PDA

Click to See Complete Forum and Search --> : As New & MTS


efrat
Jun 13th, 2000, 07:20 PM
Hi All
I need to write a component that be in MTS
But my Boss say that As New is not Good
And i need to use create Object

Why ??????

Thanks
Efrat

Clunietp
Jun 14th, 2000, 09:47 AM
I told you why!

Clunietp
Jun 14th, 2000, 09:51 AM
In case anyone else cares:

(If I remember correctly)
Use CreateObject (Actually, late binding) to instantiate objects that reside within the control of MTS. This allows the object contexts of both components to communicate, i.e. allow the calling component to determine whether the component being called completed successfully (via setcomplete or setabort)


Use AS NEW (early binding, but you can use CreateObject to achieve early binding, but I won't get into that) to instantiate objects that do not reside within MTS. You'll commonly use this for your ADO objects and the objectcontext objects, among others


Tom

Clunietp
Jun 15th, 2000, 11:29 AM
Actually, a correction

Use early binding with createobject

example:

dim objMyObject as MyMtsObject.ClassName
dim objContext as mtxas.objectcontext

set objcontext = mtxas.getobjectcontext

set objMyObject = objContext.CreateInstance("MyMTsObject.ClassName")

objMyObject.Foo()

'etc....