PDA

Click to See Complete Forum and Search --> : DB connect causing memory leak


innom
Feb 27th, 2001, 07:56 AM
Can anyone please tell me what I am doing wrong. This increases the memory by 9000k and it is not released when I do the terminate.

<code>
Private adoConnection As ADODB.Connection
Private Sub Class_Terminate()
On Error Resume Next

' Remove the Connection Object
Set adoConnection = Nothing

End Sub
Public Sub ConnectToDB(ByRef strDSN As String, ByRef strUID As String, ByRef strPWD As String)

On Error GoTo ConnectToDBErr

Dim strConnectString As String

Set adoConnection = New ADODB.Connection

strConnectString = "uid=" & strUID & ";pwd=" & strPWD & ";dsn=" & strDSN
' strConnectString = "User ID=" & strUID & ";Password=" & strPWD & ";Data Source=10.149.2.24;DSN=OracleIVRDSN"
' adoConnection.Provider = "MSDAORA"

' Establish a connection to the database
adoConnection.ConnectionString = strConnectString

adoConnection.Open

' The Database connection was opened successfully
IsOpen = True

ConnectToDBExit:
Exit Sub

ConnectToDBErr:
On Error Resume Next
' Remove the Connection Object
Set adoConnection = Nothing

' The Database connection was not opened
IsOpen = False

' Err.Raise 1008, "clsDatabaseAccess", "Could not connect to the database. No files will be processed."
addLogEntry (Err.Number + " - " + Err.Description)

Err.Raise Err.Number, Err.Source, Err.Description
Resume ConnectToDBExit

End Sub
<\Code>

Thanking you in advance!!!!

HarryW
Feb 27th, 2001, 08:11 AM
Uhh... this is the games and graphics forum...