Option ExplicitPrivate Context As ScriptingContext
Private Application As Application
Private Response As Response
Private Request As Request
Private Session As Session
Public conn As ADODB.Connection
Private rs As ADODB.Recordset
Private Server As Server
Private key As String
Public Sub OnStartPage(PassedscriptContext As ScriptingContext)
Set Context = PassedscriptContext
Set Application = Context.Application
Set Request = Context.Request
Set Response = Context.Response
Set Server = Context.Server
Set Session = Context.SessionEnd Sub
Private Sub Class_Initialize() Set conn = DbConn()End Sub
Public Function setKey(key_)
key = key_
End FunctionPublic Function getKey()
getKey = key
End Function'==========================
' connect to database
'==========================
Public Function DbConn()
Dim connstr As String
Dim conn1 As New ADODB.Connection
Set conn1 = New ADODB.Connection
connstr = "driver={sql server};database=biran;uid=sa;password=sa;server=(local);stmt=set names 'gbk'"
conn1.Open connstr
If Err <> 0 Then
Err.Clear
End If
DbConn = conn1
End Function
Public Function getRecord()Set rs = New ADODB.Recordset
rs.Open "select * from aa", conn, 1, 1
If Not rs.EOF Then
Do While Not rs.EOF
Response.Write rs("name") & "<br>"
rs.MoveNext
Loop
Else
Response.Write "none"
End If
rs.Close
End Function
Public Sub OnEndPage()
Set Application = Nothing
Set Request = Nothing
Set Response = Nothing
Set Server = Nothing
Set Session = Nothing
Set Context = Nothing
End Sub
上面这段代码,我把它的工程名改为biran 类名改为tst然后用regsvr32 biran.dll注册成功。
再在ASP中写set c=server.createobject("biran.tst")
为什么这样写会出错?
IIS好像没有什么关系吧。。这个是系统注册过的。
试试
然后在server.createObject 那一行报这个错:biran (0x800A01A8)
需要对象