3

After our VB6 program worked for many years without problem, some users have began getting intermittent file opening errors. This started three or four years ago (not sure when) only for some users.

Our development machine has never had these errors, so we cannot replicate their situation.

The program posts a batch of data from some files into another system. When the error occurs, the batch does not post, so we tell the user to try again. Sometimes they have to try many times before the run is error free.

A typical issue is error 3051 when we run OpenRecordset:

Set rs = DB.OpenRecordset(szSQL, dbOpenDynaset)

"The Microsoft Jet database engine cannot open the file 'our_file_name'. It is already opened exclusively by another user, or you need permission to view its data."

So this week we changed the error-handling in a key section of code to repeat the command after sleeping for a second.

Though this seems so far to have worked, the code is complex and difficult to maintain, with OpenRecordset in many places, so I do not want to do this everywhere. Do you have any suggestions?

I do not have access to the user's PC to check which processes might have the file open.

We are reading VFP .DBF and Access .MDB files.

PS Since my initial post, somebody suggested anti-virus software might be responsible. I am investigating this.

finch
  • 549
  • 1
  • 6
  • 18
  • 1
    I absolutely agree with AV software interfering (I was just about to post same remark). We have had issues with AV locking files for short periods; waiting one second (exactly like you did) and retrying usually helped. – Arvo Nov 20 '20 at 14:50
  • 1
    In a fairly large application I maintain, I encapsulated the OpenRecordset into a function call; such a common function would make it easy to add the retry to all occurrences, if necessary. – Mark Moulding Nov 20 '20 at 21:43
  • 1
    Might be worth checking the files aren't in DropBox or similar too. – Rob Nov 24 '20 at 15:45
  • Are you using shared database files, eg on a network server? Or are they located/installed only on the end-user's PC? And are they read/write or readonly? If readonly you could copy them to a temp location first. – StayOnTarget Nov 24 '20 at 15:47
  • The program uses databases on a network server. The files are not used by any other user or program. Some of the files are written to, which means it would be complicated copying to a temp location first. (Which I think could otherwise be a great idea.) The files are later used by other users. – finch Nov 26 '20 at 09:27
  • Have all your users full access rights to data file location (folder)? MS Access needs to create and write ldb file to track users locking; if it can't create or modify it, then it opens database in readonly mode. Of course AV can interfere too, – Arvo Apr 28 '21 at 10:24
  • We expect users do have full access to the data folder, but this is certainly something to check when the error next comes up. (It has not recurred for some weeks.) Would it explain intermittent errors for the same user? – finch Apr 29 '21 at 11:56

0 Answers0