如果在代码中使用了数据控件如 DAO, RDO,或ADO,在退出时应该关闭所有打开的recordset,database,和workspace。虽然对象能自动注销,但是数据连接不会马上断开,可能会导致一些内存不能被系统重新分配。下面的代码可以关闭所有打开的DAO workspace,并释放所占的内存。Private Sub Form_Unload(Cancel As Integer)On Error Resume Next\'Dim ws As WorkspaceDim db As DatabaseDim rs As Recordset\'For Each ws In WorkspacesFor Each db In ws.DatabasesFor Each rs In db.Recordsetsrs.CloseSet rs = NothingNextdb.CloseSet db = NothingNextws.CloseSet ws = NothingNext\'End Sub
共 1 个关于本帖的回复 最后回复于 2013-7-11 13:55