How to count how many instances of a program are running from a shared folder?

Asked

Viewed 79 times

1

I am developing an application that runs from a shared folder. In the same folder is the Access database. To avoid conflicts in Access, it will only be allowed to run by only one user at a time, and two users of different machines will not be allowed to run the application at the same time.

I thought of a Usitan method, creating a temporary file every 5 min, containing the current date and time. Where, if another user tries to run the application and this file exists in the folder, its access is not allowed. And, if there is a bug in the execution of the first instance and the file stays in the folder, if it was created more than 5 min ago, a new access is allowed.

Is there any more 'elegant' method for this type of control?

  • 2

    I have the impression that any method will be Lusitan (or worse than that). The ideal would be to make a solution that does not depend on it.

  • But then would it be possible with the ms-access bank? It would have to migrate to Sqlserver?

  • I don’t think so. Access is a solution for very basic use. Even Sqlite is better than Access, although in this scenario it will be potentially problematic as well. It is a case that a server would be suitable.

1 answer

1

@Wouldn’t Leandro be the case if you open Access in exclusive mode? If you are using OLE DB, adjust your Connection String adding Mode=12; Getting something like

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\northwind.mdb;Mode=12;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.