Disconnecting From a Database

After database connection and access are complete, applications must disconnect from the database to properly release unmanaged resources. These unmanaged resources are provided to DCS by the Common Language Runtime (CLR) for network access. In general, DCS and the CLR will not release these unmanaged resources for you, and if not released, unexpected results, including loss of data, can occur. You must explicitly release unmanaged resources associated with AdgConnection objects using the AdgConnection.Close or AdgConnection.Dispose methods. You should call one of these methods before the AdgConnection variable loses scope or is reassigned.

[C#]
  Cx.Close();
  Cx = null;
[Visual Basic]
  Cx.Close()
  Cx = Nothing
        [Visual RPG]
  Cx.Close()
  Cx = *Nothing

Whether you use AdgConnection.Close or AdgConnection.Dispose is a matter of preference since they perform the same task of disconnecting the database and releasing unmanaged resources. Note that AdgConnection.Dispose implements the conventional System.IDisposable interface for AdgConnection.