Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21993

Disconnected recordset doesn't release database login - Unidata

$
0
0
I have inherited a VB 6 application that is using the Informix Unidata ODBC driver to retrieve data from Primac. After I close the connection and destroy the connection object, I am still logged in to the Primac database. The login to the database doesn't go away until the program is closed. This code is on the Logon form. Even after the logon form is closed, the database login doesn't go away until I close the program. Anyone know how to force the database login to go away? I'm trying to free up Primac licenses by closing the connection when it's not in use. If this were .Net, I'd be thinking Garbage Collection. But I can't find any VB 6 equivalent. Here's the code:


Private Function GetPrimacConnection(strUID, strPWD, strError) As Boolean
On Error GoTo ErrorPrimac
Dim unidb As ADODB.Connection
strUniConn = "PROVIDER=MSDASQL;dsn=PRIMAC_QA;uid=" & strUID & ";pwd=" & strPWD & ";"
Set unidb = New ADODB.Connection

With unidb
.CursorLocation = adUseClient
.ConnectionString = strUniConn
.Open ' Opening the database successfully proves that the user is valid.
End With

GetPrimacConnection = True

unidb.Close
Set unidb = Nothing
Exit Function
ErrorPrimac:
strError = Err.Description
GetPrimacConnection = False
If Not unidb Is Nothing Then
If Not unidb.State = adStateClosed Then
unidb.Close
End If
Set unidb = Nothing
End If
End Function

Thanks in advance for any suggestions.

Viewing all articles
Browse latest Browse all 21993

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>