To read the article online, visit http://www.4GuysFromRolla.com/webtech/043099-1.shtml

Server.CreateObject vs CreateObject

By Ryan S.


If you have ever read a tutorial on component building, you will have undoubtbly seen a few ways to invoke the component. These two ways are Server.CreateObject and CreateObject. But more than likely you probably wonder what is up with that, is there really a difference. Actually, there is.

Server.CreateObject invokes Microsoft Transaction Server (MTS) to create the object and handle it, whereas CreateObject goes straight to it.

While I have found no articles written on these two, the conclusion comes from the fact that if you have an erroneous object, CreateObject gives you an error, but when you do Server.CreateObject, it gives you an error and logs an error in the event log, viewable via Event Viewer.

This can become significant if you are writing a component that deals with transactions, as it would be a good safety net to pass it through MTS, because you will be using MTS commands. However, if you are not using MTS, you could create processor and memory over head by passing it through Server.CreateObject. This makes it a better idea to use CreateObject, because it goes straight through.

I hope you understand the difference now, and when to use the two.

God Bless from Ryan S


Article Information
Article Title: Server.CreateObject vs. CreateObject
Article Author: Ryan S.
Published Date: Friday, April 30, 1999
Article URL: http://www.4GuysFromRolla.com/webtech/043099-1.shtml


Copyright 2017 QuinStreet Inc. All Rights Reserved.
Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers