- 中查找“用VB 6封装ASP代码, 制作DLL组件”更多相关内容
- 中查找“用VB 6封装ASP代码, 制作DLL组件”更多相关内容
- ·上一篇文章:在ASP中实现购物小车 二
- ·下一篇文章:已经没有了
用VB 6封装ASP代码, 制作DLL组件
object library"
和"microsoft activeX data objects 2.1 library"两项。将类模块的名称改为dcss.将工程的名称
改为yygwy.保存工程文件yygwy.vbp和类文件dcss.cls。
在dcss.cls中写入:
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 rsresult(strsql As String) As Recordset
Dim mycnn As Connection
Dim myset As Recordset
Dim strconnstring As String
'strconnstring = "provider=sqloledb.1;
password=;" & "user id=sa;" & "initial catalog=vlog;" & "data source=hpe60;
connect timeout=15"
strconnstring = "driver={sql server};server=yang;uid=sa;pwd=;
database=dcss"
'mycnn.ConnectionString = strconnstring
mycnn.Open strconnstring
myset.ActiveConnection = mycnn
myset.Open strsql, mycnn, 3, adCmdText
Set rsresult = myset
End Function
Public Function datasource() As Variant
datasource = "driver={sql server};server=yang;uid=sa;pwd=; database=dcss"
End Function
编译生成dcss.dll文件。注册regsvr32 路径dcss.dll。
用visual interdev打开global.asa文件.当然了,你也可以在其它文件中使用。
set dcss=server.CreateObject("yygwy.dcss")
oconn=dcss.datasource()
application("strconn")=oconn
在其它的页面中如下调用即可:
set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open application("strconn")
Tags:
作者:佚名评论内容只代表网友观点,与本站立场无关!
评论摘要(共 0 条,得分 0 分,平均 0 分)
查看完整评论