×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

new user of MTS

new user of MTS

new user of MTS

(OP)
I am writing a VB dll,to be called from ASP. I would like to make use of MTS. I am slightly confused:

How is it different to create a regular vb DLL and install as a package in MTS

as opposed to

using the getobjectcontext() withhin the VB dll
and installing as MTS package..

MTS gurus??

Thanks in advance
NC..

RE: new user of MTS

There really isn't any difference between what you've described.

What you should do is write an Active-X DLL that in it's method calls, calls getobjectcontext() to get a reference to the context object.  You then do your thing.  At the end of the function you call either SetComplete or SetAbort.  Then set the context variable to Nothing.

Here are some design tips to make things easier for you:

1) Open and close the database connection in each method.  Do not open it in the class_init and leave it open until class_terminate -- you'll confuse MTS.  MTS is very good at caching database connections, and doing it this way is faster than you might think.

2) Do not use the "As New" method of instantiating objects.  The safest way is to always use CreateObject, even if the class you're instantiating is in your own project.

3) Have good error handling.  Having an unhandled error will confuse MTS.

4) Have only one exit point to your function.  Using "Exit Sub" or "Exit Function" all over the place leaves you open to forgetting to call the correct context method (SetComplete, SetAbort).

5) Don't use any global or module level variables.

6) If you have to maintain state for the user, do it via a cookie or via an entry in the database.  Don't use the Session object.

7) Always set your object variables to Nothing before leaving the function.

Hope this gets you started.

Chip H.

RE: new user of MTS

(OP)
thanks for the response Chip.

So if i use
server.createobject for all my connections and recordsets, and not use object context at all and still register my dll under a MTS application, is it helpful in any way..

ie. is it better than just writing a vb dll and not creating an app out of it in MTS??

your tips are very helpful too!!
thanks in advance..

RE: new user of MTS

Our GUI layer is very thin -- most of the time all it does is call server.createobject and pass it parameters (usually XML strings).  We did this because writing/debuging ASP and javascript code in Interdev is much harder than debugging VB code in the VB IDE.  So, we write a VB DLL that does all our business logic and run it under COM+.  Our ASP code would then call into this DLL (and other DLLs) for everything.

One other thing, you don't actually need to get a reference to the object context if what you're doing doesn't require a transaction.  If all you're doing is SELECTing records, no transaction is required.  But if you INSERT, UPDATE, or DELETE records, it should be done inside a transaction.  What we did is create a class in our DLL for our non-transactional needs, and another one for the transactional operations.  The MTS property on the classes was set appropiately.  For example:

Non-transactional class:
    MTSTransactionMode = 0 - Not an MTS object
    No references to object context

Transactional class:
    MTSTransacitonMode = 2 - Requires Transaction
    Gets reference to object context, calls SetComplete and SetAbort as appropiate

If we need to go get a record from inside the transactional class, we just instantiate a copy of the non-transactional class and call the correct "fetch" method.  Since the non-transactional class doesn't know or care about transactions, and isn't doing anything that would require a transaction, everything is OK.


Hope this helps.

Chip H.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close