启动vb6.0,新建-->Active dll工程。单击"工程"-->引用,选择"microsoft active server pages
object library"
和"microsoft activeX data objects 2.1 library"两项。将类模块的名称改为dcss.将工程的名称
改为test.保存工程文件test.vbp和类文件dcss.cls。
在dcss.cls中写入:
Option Explicit
Private myscriptingcontext As ScriptingContext
Private myapplication As Application
Private myrequest As Request
Private myresponse As Response
Private myserver As Server
Private mysession As Session
Private Myconn As ADODB.Connection
Private strSql As String
Public Property Get augend() As String
augend = strSql
End Property
Public Property Let augend(vNewValue As String)
strSql = vNewValue
End Property
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
Set Myconn = New ADODB.Connection
'Dim myset As Recordset
Dim strconnstring As String
strconnstring = "driver={sql server};server=DING;uid=sa;pwd=;database=serving"
Myconn.Open strconnstring
Dim rs As New ADODB.Recordset
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 Sub result()
Myconn.Execute (strSql)
myresponse.Write ("ok")
End Sub
编译生成test.dll文件。注册regsvr32 路径test.dll。
sql="insert into type(type) values('dss')" set dcss=server.CreateObject("test.dcss")
dcss.augend=sql
dcss.result()