I have noticed recently the incorect setting of Data Types that wont be released (Set to Nothing).

If you are referencing the AX ADO Lib (or DAO) the following should apply:

VB Code:
  1. 'Eg.
  2. Dim rst as ADODB.Recordset
  3.  
  4.   Set rst = [b]New[/b] ADODB.Recordset
  5.  
  6.  
  7.   'Code here
  8.   '
  9.   '
  10.  
  11.  
  12.   Set rst = Nothing

This example below by Armbruster shows why:
In my example the dim statement declares an object variable of type adodb.recordset. Because I did not use the NEW keyword in the dim statement, it did not create the object from the adodb.recordset class. The set statement then creates the object from the underlying class.

So what is the difference with my example and yours? The difference has to do with how COM implements the underlying class.

There was a lengthy discussion on the board quite some time ago. Basically, your example will not totally release the memory after the object is destroyed because of the way the class is implemented by dim as a new object in the same statement.

Run this code . . .
VB Code:
  1. Private Sub Command1_Click()
  2.     Dim ado1 As New ADODB.Recordset
  3.     Dim ado2 As ADODB.Recordset
  4.     Set ado2 = New ADODB.Recordset
  5.     Set ado1 = Nothing
  6.     Set ado2 = Nothing
  7.     If ado1 Is Nothing Then
  8.         MsgBox "ado1 properly destroyed"
  9.     Else
  10.         MsgBox "ado1 is still around"
  11.     End If
  12.     If ado2 Is Nothing Then
  13.         MsgBox "ado2 properly destroyed"
  14.     Else
  15.         MsgBox "ado2 is still around"
  16.     End If
  17. End Sub



Bruce.