2016-08-31 35 views
0

我有一個VB6應用程序,我從數據庫中獲取一些數據。 我在關閉創建的會話時遇到問題。VB6 CreateObject(「OracleInProcServer.XOraSession」)無法關閉會話

即使將會話對象設置爲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 

在這方面的任何幫助將不勝感激。

回答

0

objCursor應該給你使用close而不是沒有的選項 - objCursor.Close