The two subjects are related only because they do similar things:
Using stored procedures is typically done either as a performance enhancement, or to hide messy details from a caller.
Using a COM+ component is typically done either as a performance enhancement, or to hide messy details from a caller.
So, you can do one, the other, or both, depending on what your requirements are. If your site/application will be serving a large number of clients, then you'll want the performance benefits of doing both. Read similar threads here about designing stateless components vs. components that maintain state.
The reason you have to implement the ObjectControl interface is so that COM+/MTS can call into your component. Once to see if your component can be pooled, and then whenever the component is activated or deactivated. Any code you had in class_initialize before should be moved into the ObjectControl_Activate method.
The other thing you should do, is if the class you're writing needs to be in a transaction (i.e. everything that happens in a method call must succeed or it must fail, no exceptions) is to insert calls to the ObjectContext object. Call .SetComplete when everything was done successfully and you want to commit your database changes. And call .SetAbort when an error occurred -- COM+ will then handle the database rollbacks for you and no data will be saved.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.