VB6 CreateObject(“OracleInProcServer.XOraSession”)无法关闭会话

时间:2016-08-31 12:39:37

标签: oracle session vb6 createobject

我有一个VB6应用程序,我在其中从数据库中获取一些数据。 关闭创建的会话时遇到问题。

即使我将会话对象设置为Nothing,看起来也会保留会话。似乎只有在我关闭应用程序时它才会关闭。

我使用以下查询来检查数据库中的会话。

SELECT * FROM v$session where terminal='VirtualMachineName';

以下是代码,

Dim pCounter As Long, strLoadSQL As String
Dim objCursor As OraDynaset
Dim tmpDBSessobj As OracleInProcServer.OraSession
Dim tmpDBClientobj As OracleInProcServer.OraDatabase
Dim objresetGI As GameInfo

On Error GoTo ErrorHandler

Set tmpDBSessobj = CreateObject("OracleInProcServer.XOraSession")
Set tmpDBClientobj = tmpDBSessobj.OpenDatabase(strDBServiceName, strDBUsernamePassword, ORADB_ORAMODE)

'set autocommit false ---
tmpDBClientobj.AutoCommit = False

'set params
Do Until tmpDBClientobj.Parameters.Count = 0
    For pCounter = 0 To tmpDBClientobj.Parameters.Count - 1
        tmpDBClientobj.Parameters.Remove pCounter
    Next
Loop
'bind
tmpDBClientobj.Parameters.Add "ocursor", Nothing, ORAPARM_OUTPUT
tmpDBClientobj.Parameters(0).serverType = ORATYPE_CURSOR

'declare proc signature
strLoadSQL = "begin resetpackage.getresetID(:ocursor); end;"

'reset this game
tmpDBClientobj.ExecuteSQL (strLoadSQL)
Set objCursor = tmpDBClientobj.Parameters(0).Value

'load the list box
If objCursor.RecordCount > 0 Then
    argscollection.Clear
    objCursor.MoveFirst
    Do Until objCursor.EOF
        objresetGI.strGameNo = objCursor.fields(0).Value
        objresetGI.strAction = objCursor.fields(1).Value
        objresetGI.strProcessInd = objCursor.fields(2).Value
        argscollection.Add objresetGI, objCursor.fields(0).Value
    objCursor.MoveNext
    Loop
End If

Set objCursor = Nothing
tmpDBClientobj.Close
Set tmpDBClientobj = Nothing
Set tmpDBSessobj = Nothing

在这方面的任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

objCursor should give you the option to use close and not nothing - objCursor.Close