ADO Code

  • Hi Eric,

    thanks for this indeep explanation!

    As for David,

    quote:


    I know ASSuME makes an ASS of you and ME and Assumption is the mother of all F*** ups.


    I'm not sure, if I understand this correctly although I've tried until now. Could you mail me a short explantion offline ?

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • From http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnserv/html/server01242000.asp

    Server.CreateObject vs. CreateObject

    Recommendations

    Use Server.CreateObject. If you're using MTS/COM+ library packages, use Server.CreateObject to avoid blocking of threads.

    Why

    CreateObject equates to calling CoCreateInstance by the scripting engine. If you use CreateObject instead of Server.CreateObject, the following things occur:

    ASP is not aware of the object.

    OnStartPage/OnEndPage page methods are not called.

    ASP does not know the threading model of the object.

    Server.CreateObject equates to GetObjectContext.CreateInstance. This means ASP is aware of the object and knows its threading model. In addition, by calling Server.CreateObject, your component will be in the same transaction as your ASP page if your ASP page is transactional. (Just note that a transactional page may imply an avoidable coupling of business rules and the presentation layer.)

    quote:


    quote:


    Hi Frank,

    Yes, laziness on my part. If you leave off 'Server.' it is assumed (bad practice ).

    I know ASSuME makes an ASS of you and ME and Assumption is the mother of all F*** ups.

    p.s. This is server side scripting.

    Edited by - davidburrows on 07/07/2003 06:29:03 AM


    Actually there is no overhead if you leave off Server. from CreateObject.. But there is a difference.

    Server.CreateObject("Object") invokes the Microsoft Transaction Server (MTS) to create the object and handle it, where CreateObject simply goes straight to it.

    If you try to instantiate an object via CreateObject that is erroneous, CreateObject will throw an error and that's it. Server.CreateObject, in the same situation, will throw an error and also log the error in the event log.

    If you're using a component that deals with transactions (such as the ADODB set of objects do) It's good practice to use Server.CreateObject to let MTS control it. But if you're not using transactions you'll create uneeded cpu and memory overhead by using Server.CreateObject, so in that instance its good practice to pipe it through CreateObject.

    Regards,

    ~Eric


Viewing 2 posts - 16 through 16 (of 16 total)

You must be logged in to reply to this topic. Login to reply