473,385 Members | 1,983 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to avoid (undesired, intermittently-occurring) exclusive locks?

sueb
379 256MB
I have a database whose back end sits on a server, and each user has their own front end on their computer's desktop. Periodically (infrequently), for the first user to open their front end in the morning, Access writes an exclusive lock on the server, and no one else is able to get in until that user exits.

Is there a way for me to put into the front end something that would look at the lock and, if it were exclusive (and assuming Access can detect this internally) to have the front end close itself ("Application.Quit")? So far, it's never done this immediately a second time (personally, I think it's an Access bug), so I think this would solve this problem for us.

Any other suggestions about this will be eagerly accepted, as well!
Jun 24 '11 #1

✓ answered by NeoPa

First off, I was looking at the wrong setting in my first reply. I was in a bit of a rush. It should have been the Default Open Mode option. That said, the parameter value for that is not "Default Open Mode", and I was unable to find what it was anywhere :-(

This only sets and shows the default mode. Not the current mode. The Default Open Mode can be overridden by the command used to invoke Access, either from a Command Line or a Shortcut.

The Option displayed is simply the Option (Default). There is no Option for the current setting of the Open Mode.

The following code determines this for you. As it stands it simply displays the value in the Immediate Pane of the VBA IDE, but can easily be changed to suit your needs :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.     Dim intFileNo As Integer
  3.     Dim strOpenMode As String
  4.     On Error Resume Next
  5.  
  6.     intFileNo = FreeFile
  7.  
  8.     Open CurrentProject.FullName For Input Access Read Shared As #intFileNo
  9.     Close #intFileNo      ' Always close the file.
  10.     strOpenMode = IIf(Err = 70, "Exclusive", "Shared")
  11.     Debug.Print strOpenMode
  12.     '------------------------------------------------------------------------
  13.     '  If this file was opened and closed successfully, then it
  14.     ' was opened in shared mode.
  15.     '------------------------------------------------------------------------
  16. End Sub

13 4086
NeoPa
32,556 Expert Mod 16PB
No time now for full research, but you could start by looking into Application.SetOption("Default Record Locking", ...).
Jun 24 '11 #2
sueb
379 256MB
Thanks, NeoPa! I'll certainly do that, and will post back anything useful I discover.
Jun 24 '11 #3
sueb
379 256MB
Here's something:

On the Microsoft support site, there is this paragraph in the article "ACC: Introduction to .LDB Files (1.x/2.0)":

"However, the .LDB file does not give Microsoft Access information about who has a database opened exclusively, because this is handled by SHARE.EXE (or VSHARE.386 in Windows 3.1). Those programs do not return information to Microsoft Access about who has the database open."

So it begins to look as though I actually will not be able to get at the type of lock that has been created. Still researching, tho...
Jun 24 '11 #4
NeoPa
32,556 Expert Mod 16PB
Interesting Sue, but if each instance of the opened database is checked for the sharing mode and curtailed if exclusive, then that may still get around the issue. It's worth progressing with I'd say.
Jun 24 '11 #5
sueb
379 256MB
The problem is that I don't (so far) see any way of actually finding out whether a lock is shared or exclusive.
Jun 24 '11 #6
NeoPa
32,556 Expert Mod 16PB
I think you're going to wish you hadn't asked that one Sue. Try :
Expand|Select|Wrap|Line Numbers
  1. Application.GetOption("Default Record Locking")
Jun 24 '11 #7
sueb
379 256MB
:) Well, I already know what the "default" is; will this give me what the "current" is?
Jun 24 '11 #8
NeoPa
32,556 Expert Mod 16PB
First off, I was looking at the wrong setting in my first reply. I was in a bit of a rush. It should have been the Default Open Mode option. That said, the parameter value for that is not "Default Open Mode", and I was unable to find what it was anywhere :-(

This only sets and shows the default mode. Not the current mode. The Default Open Mode can be overridden by the command used to invoke Access, either from a Command Line or a Shortcut.

The Option displayed is simply the Option (Default). There is no Option for the current setting of the Open Mode.

The following code determines this for you. As it stands it simply displays the value in the Immediate Pane of the VBA IDE, but can easily be changed to suit your needs :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.     Dim intFileNo As Integer
  3.     Dim strOpenMode As String
  4.     On Error Resume Next
  5.  
  6.     intFileNo = FreeFile
  7.  
  8.     Open CurrentProject.FullName For Input Access Read Shared As #intFileNo
  9.     Close #intFileNo      ' Always close the file.
  10.     strOpenMode = IIf(Err = 70, "Exclusive", "Shared")
  11.     Debug.Print strOpenMode
  12.     '------------------------------------------------------------------------
  13.     '  If this file was opened and closed successfully, then it
  14.     ' was opened in shared mode.
  15.     '------------------------------------------------------------------------
  16. End Sub
Jun 24 '11 #9
sueb
379 256MB
Okay, that's interesting. Just so I understand what's happening: first it Opens the current project to get the filename, then it attempts to Close it, which (I gather) gives an error, and this error will tell me whether the mode is "Exclusive" or "Shared".

That means, does it not, that if it came back "Exclusive", I could have the application shut itself down? That would be wonderful!
Jun 28 '11 #10
NeoPa
32,556 Expert Mod 16PB
Actually, I believe the Open triggers the error. The Close is simply there to keep the code tidy (If the Open succeeded and it wasn't closed you'd leave an open table doing nothing but taking up resources and potentially even locking the file). Essentially though, yes you should be able to use it that way.
Jun 28 '11 #11
sueb
379 256MB
Lovely, NeoPa! I'll put that in and see if it doesn't do the trick for me. Thanks!
Jun 28 '11 #12
sueb
379 256MB
NeoPa, naturally, your answer in #9 was perfect. Thanks so much!
Jul 6 '11 #13
NeoPa
32,556 Expert Mod 16PB
Always a pleasure Sue. Happy coding :-)
Jul 6 '11 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Bruno Barberi Gnecco | last post by:
I'm developing a collaborative application in PHP which accesses local files and may modify them. How can I synchronize the multiple accesses? Note that I'm not worried about the algorithmic part...
17
by: Dr NoName | last post by:
Help! I have a table that multiple processes must be able to write to concurrently. However, it for some reason gets locked in exclusive mode. I narrowed it down to one SQL statement + some...
0
by: Bruce Pullen | last post by:
DB2 v7.2 (FP7 - DB2 v7.1.0.68) on AIX 5.2.0.0. We're seeing unexpected single row (then commit) insert locking behaviour. We're seeing Applications that already hold row-level W locks in...
0
by: Jigar Mehta | last post by:
Hye, In my program I am locking some files exclusively during critical process... But after that, I loose those file's pointer, Now in another module, I have to remove all exclusive locks pushed...
4
by: Alex Callea | last post by:
Hi there, We have a web application handling thousands of requests per seconds reading sql server data which is heavily updated. We are generally experiencing no performance problems. On some...
4
by: michael.schmitz | last post by:
We have developed a large PHP application using adodb-4.22, php-4.2.2 and IBM DB2 v8.2 and saw that simple select statements in our code like Execute('select * from sesys.role order by role_id')...
22
by: RayPower | last post by:
I'm having problem with using DAO recordset to append record into a table and subsequent code to update other tables in a transaction. The MDB is Access 2000 with the latest service pack of JET 4....
9
by: kavallin | last post by:
I receives the following in the db2diag.log file many times / day : 2007-03-05-14.55.24.836553+060 E12415C457 LEVEL: Warning PID : 2785 TID : 1 PROC :...
7
by: praveen | last post by:
Hi When does DB2 go for an IS (Intent Share) lock? IS mode is defined as a mode in which "The lock owner can read data in the locked table, but cannot update this data. Other applications can...
4
by: Mateusz Mrozewski | last post by:
Hi, Is there a difference between: SELECT * FROM mytable WHERE somecolumn='Y' FOR UPDATE WITH RS and SELECT * FROM mytable WHERE somecolumn='Y' FOR UPDATE WITH RS USE AND KEEP UPDATE LOCKS I...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.