启动vb6.0,新建-->ActiveX dll工程。
单击"工程"-->引用,
选择 "microsoft active server pages object library"
和 "microsoft activeX data objects 2.1 library"两项。
根据需要,修改类名和工程名。
Private myscriptingcontext As ScriptingContext
Private myapplication As Application
Private myrequest As Request
Private myresponse As Response
Private myserver As Server
Private mysession As Session
Public Sub onstartpage(passedscriptingcontext As ScriptingContext)
Set myscriptingcontext = passedscriptingcontext
Set myapplication = myscriptingcontext.Application
Set myrequest = myscriptingcontext.Request
Set myresponse = myscriptingcontext.Response
Set myserver = myscriptingcontext.Server
Set mysession = myscriptingcontext.Session
End Sub
Public Sub onendpage()
Set myscriptingcontext = Nothing
Set myapplication = Nothing
Set myrequest = Nothing
Set myresponse = Nothing
Set myserver = Nothing
Set mysession = Nothing
End Sub
'以上语句是必须的。
'增加一个函数 Public Function ds() As Variant
ds = "driver={sql server};server=yang;uid=sa;pwd=; database=dcss"
End Function
Public Function das(connstr As Variant,filename As Variant) As Variant
' 变量类型和返回必须为:Variant 。否则Asp调用的时候,传字符串进来,会出现类型不匹配的错误。
End Function
ASP调用如下:
set rs=server.CreateObject("工程名.类名") ‘ 我用的是 set rs=CreateOjbect("工程名.类名")
oconn=rs.ds()
关联文章:
32位DLL注册到64位系统下,需要把IIS中的“启用32位应用程序改为:true