开发者

How to properly remove all connections to an Access Database

开发者 https://www.devze.com 2022-12-13 03:11 出处:网络
Here\'s a snippet of VB6 code: myProjectDaoDB.Close FileCopy myName, TempFile where myName is the path of a database.This database is presumably closed in the first line. It seems that simply closi

Here's a snippet of VB6 code:

myProjectDaoDB.Close
FileCopy myName, TempFile

where myName is the path of a database. This database is presumably closed in the first line. It seems that simply closing the database is not enough to properly remove all access to database since when I run the program, I get a run-time error of '70': Permission denied. I know that there are no actual problems with the user permissions. This error only 开发者_如何转开发happens after saving to the database, so I'm sure that something isn't being closed properly.

When the database is open, a lock file is created. If I run this code without making any changes to the database, the lock file is deleted after the first line runs. When I make changes to the database, the lock file is not deleted. There are no errors when it tries to close database, so why is it still there?

Update: I've followed the steps here to find out who has a connection to the database during the error. According to the results, When I try to close the connection without making changes to the database, it's only my connected. When I make changes, I'm connected twice. It seems then that myProjectDaoDB.Close is not closing all the connections. What gives?


Have you closed all the recordsets and set their object to Nothing?


It might be worth trying DBEngine.Idle dbRefreshCache

0

精彩评论

暂无评论...
验证码 换一张
取 消