VB6错误:对象变量或未设置块变量



我明白了

"dblog"子函数中的"对象变量或未设置块变量">

在这一行中,我猜是带有"m_Session"

If iType >= Int(m_Session("_SysParam_LogLevel")) Then

我的代码


Private m_Session As ASPTypeLibrary.Session
Public Function InitializeSite(Optional intCheckMode As Integer = 0) As Boolean
InitializeSite = False
Dim cmd As ADODB.Command
Dim rs As ADODB.Recordset
DBLog "Initializing started - "
Set cmd = New ADODB.Command
Set rs = New ADODB.Recordset
With rs
.ActiveConnection = DBConnection
end with
end function
Public Sub DBLog(ByVal sTxt As String, Optional ByVal iType As Integer = 0, Optional ByVal sCategory As String = "DEBUG")
'On Error Resume Next
Dim cmd As ADODB.Command
If iType >= Int(m_Session("_SysParam_LogLevel")) Then
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = DBConnection
End With
End If

Set cmd = Nothing
On Error GoTo 0
End Sub
Property Get DBConnection() As String
DBConnection = IIf(Not IsNull(m_Session("_SysParam_DBConnection")), m_Session("_SysParam_DBConnection"), "")
End Property

请帮助我前进。

函数 InitializeSite 也应该在调用 DBLog sub 之前初始化变量m_Session,或者您可以在 DBLog sub 中添加修改代码

If m_Session Is Nothing Then Exit Sub 

一开始。

或者你可以初始化变量m_Session将此子添加到你的类中

Public Sub OnStartPage(SC As ASPTypeLibrary.ScriptingContext)
Set m_Session = SC.Session
End Sub

看看如何将ASP经典会话变量从ASP共享到VB6?

尝试将第一行代码替换为:

Private m_Session As new ASPTypeLibrary.Session

相关内容

  • 没有找到相关文章

最新更新