Microsoft KB Archive/109957

= ACC: Introduction to .LDB Files (1.x/2.0) =

Article ID: 109957

Article Last Modified on 1/26/2005

-

APPLIES TO


 * Microsoft Access 1.0 Standard Edition
 * Microsoft Access 1.1 Standard Edition
 * Microsoft Access 2.0 Standard Edition

-



This article was previously published under Q109957



Novice: Requires knowledge of the user interface on single-user computers.



SUMMARY
Q: What is an .LDB file and what is it used for?

A: The .LDB file maintains lock information about a database, and each user who opens the database has an entry in it. The .LDB file contains the computer and user names of all users currently accessing a database in a multiuser (network) environment. No  other information is read from or written to the .LDB file.

Microsoft Access uses this information to tell which records are locked in a database, and who has them locked, to prevent possible file contention errors and database corruption by multiple users.

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.

Q: Can I find out the structure of the .LDB file?

A: The format of the .LDB file is not published and is subject to  change or elimination in future releases of Microsoft Access. Therefore, code written to manipulate it or to read its current format may not work correctly if the .LDB file is eliminated or its format is changed in a future release.

Q: Can a user or programmer gain access to the information in the .LDB file?

A: No. The information in the .LDB file is only used internally by  Microsoft Access and is not designed to be used by users or programmers.

Q: Where and when is an .LDB file created?

A: An .LDB file is created when you open a database. The .LDB file must reside in the same directory as that database. If an .LDB file isn't  present and Microsoft Access requires it, Microsoft Access attempts to create one in the same directory as the database.

Normally, the .LDB file must be in a directory where the user has read-write permissions. However, it is possible to open a database in a directory or device where a user has read-only permissions. To do this, select both the Read Only and the Exclusive check boxes in the Open Database dialog box. The Open Database dialog box can be found by selecting Open Database from the File menu. The combination of read-only and exclusive means that users will not be  updating any database information, so record-locking isn't   required. Because record-locking isn't required, Microsoft Access does not attempt to open or create an .LDB file.

This technique also works with directories where the user has read- write permissions and will improve performance if database updating isn't required.

Q: If you move a database, do you also need to move its .LDB file?

A: It isn't necessary to move the .LDB file, because Microsoft Access attempts to re-create the .LDB file if it is not present.

A potential problem can occur if the database is placed in a  directory where some users have directory read-only permissions and other users have directory read-write permissions.

When read-only users open a database, no information is written to the .LDB file, because those users are not allowed to write any information to the database. When read-write users open a database, their names and computer information are written to the .LDB file.

If both of these users (read-only and read-write) open a database and read the same record, a file conflict occurs if the read-write user attempts to update the record, because an update action would conflict with the read-only user. When a file conflict occurs, Microsoft Access pulls data from the .LDB file for what it thinks is the read-only user and uses this data in the file conflict error message given to the read-write user. However, because the read-only user's name and computer weren't written to the .LDB file, and because previously used .LDB files contain the names of previous read-write users, Microsoft Access reads old, outdated user information from the .LDB file and subsequently uses it in the error message instead of valid user information.

To protect against this problem, the database should first be  opened and then closed by one of the read-write users before any read- only users open the database. This creates the .LDB file for that database.

Q: Can I erase the .LDB file?

A: You can erase the .LDB file if no one currently has it open. However, unless the database is opened as read-only and exclusive, Microsoft Access will re-create the file the next time the database is opened.

In fact, if you receive strange user names reported (such as old user  names or garbage) when a lock conflict occurs, your .LDB file is   most likely damaged. If you suspect this, it is best to erase your old .LDB file and let Microsoft Access automatically create a new one for you.

Q: What is the maximum size the .LDB file can be?

A: The maximum size is 16K, with each active user taking 64 bytes.

Q: When is information written to the .LDB file?

A: Information is only written to the .LDB file once, when a user opens a database and the .LDB file is created, and active user information is written to it. After that point, Microsoft Access only locks portions of the .LDB file and does not read from it or  write to it.

Q: How does Microsoft Access use the information in the .LDB files?

A: Microsoft Access uses .LDB file information to determine who has which files (or records in a file) locked. If Access detects a lock conflict with another user, it reads the .LDB file to get the computer and user name of the user who has the file or record locked. However, the state of the information in the .LDB file has no bearing on the state of the database. If the .LDB file is  completely corrupted, everything in the database will still work correctly (although user names reported in lock conflicts might  look strange).

In most lock conflict situations, you get a generic "Write conflict" error message that allows you to save the record, copy it to the Clipboard, or drop the changes you made. In some circumstances, however, you receive the following error message:

Couldn't lock table ; currently in use by user on computer.

Q: How can I find out which users are accessing my database?

A: Microsoft Access does not provide direct functionality to identify users accessing a database. The level and type of functionality in  this area differs and depends largely on the operating system and network software.

For example, Microsoft Lan Manager provides an Audit API function set that can be used to create and manage real-time audit files. These audit files keep track of server operations and the users who perform them. These API functions can be manipulated through Access Basic to provide user information.

Some operating systems (such as Windows for Workgroups, which comes  with a tool called NetWatch) give you the ability to identify users logged onto a shared network directory. However, NetWatch cannot indentify users currently accessing a given file.

