当前位置: 首页 > 图文教程 > 网络编程 > ASP > 用VB6创建MTS组件

ASP
提高SQL的执行效率的ASP的五种做法
asp的offset的一个go to page
asp中command的在单条记录时,有些字段显示为空的问题
asp,php一句话木马整理方便查找木马
asp 合并记录集并删除的sql语句
asp下循环一行多少个
asp循环行数输出函数
asp access重新开始编号
ASP生成数字相加求和的BMP图片验证码
静态页面利用JS读取cookies记住用户信息
比较详细的Asp伪静态化方法及Asp静态化探讨
asp Response.flush 实时显示进度
Asp高级故障解决以及相关代码
asp智能脏话过滤系统v1.0
ASP文件中的安全问题
Access数据库中“所有记录中均未找到搜索关键字”的解决方法
asp两组字符串数据比较合并相同数据
asp MYSQL出现问号乱码的解决方法
asp文章中随机插入网站版权文字的实现代码
ASP利用XMLHTTP实现表单提交以及cookies的发送的代码

ASP 中的 用VB6创建MTS组件


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 153 ::
收藏到网摘: n/a

  随便贴贴,学过VB的人都应该知道的,不好意思。
'**********************************************************************************************
'                 MTS VB6 COM Component Template - by Michael Gonzalez
'**********************************************************************************************
'(1) You must create a reference to the Microsoft Transaction Server Type Library (mtxas.dll).
'    If using Windows 2000, choose the COM+ Services Library (comsvcs.dll) instead.
'(2) Set your ClassModule's MTSTransactionMode property to 2 - RequiresTransaction
'    Note: ONLY use 2 - Requires Transaction if you plan on using the component with an MSDTC-
'    compliant Resource Manager such as MSMQ or SQL Server - OTHERWISE, use
'    1 - No Transactions
'(3) Make sure your project's Unattended Execution property is checked
'(4) Make sure your project's Component Version Compatibility is set to Binary Compatibility
'**********************************************************************************************
'  ObjectControl implements the interface that is used by MTS when the object is
'   activated and/or deactivated - this happens when you call one of the components's methods
'  The ObjectControl implementation makes use of three procedures:
'   1) ObjectControl_Activate
'   2) ObjectControl_CanBePooled
'   3) ObjectControl_Deactivate
'**********************************************************************************************
Implements ObjectControl

Dim objOC As ObjectContext

Public Sub Something()
    'This is a user-defined procedure/method
    'The ObjectContext Object is returned by GetObjectContext
    
    On Error GoTo Abort
    
    '*******************************************************
    '       Perform whatever you want in this area
    '       Visual Basic 6 stuff goes here
    '       The Something() procedure/method is just
    '       an example - you may use properties and other
    '       methods/procedures as well!
    '*******************************************************
    
Finished:
    objOC.SetComplete
        Exit Sub
Abort:
    objOC.SetAbort
        Err.Raise Err.Number, Err.Source, Err.Description
        Exit Sub
End Sub

Private Sub ObjectControl_Activate()
    'MTS invokes this procedure/method when the component/object is instantiated
    Set objOC = GetObjectContext()
    Exit Sub
End Sub

Private Function ObjectControl_CanBePooled() As Boolean
    'This enables MTS object pooling (not currently supported my MTS 2.0)
    ObjectControl_CanBePooled = True
End Function

Private Sub ObjectControl_Deactivate()
    'MTS invokes this procedure/method right before the component/object is released
    Set objOC = Nothing
    Exit Sub
End Sub