微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

VB6生成DLL,供Asp调用

启动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







版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐