ACC97: How to Read .LDB Files
ID: Q186304
|
The information in this article applies to:
SUMMARY
Advanced: Requires expert coding, interoperability, and multiuser skills.
In Microsoft Access 97, the .ldb file is used to determine which records
are locked in a shared database and by whom. It is created automatically
when any user opens a database and deleted when the last user closes the
database. While the .ldb file cannot be opened directly for reading,
Microsoft provides a dynamic link library that exposes functions that you
can use to read the .ldb file. This article contains sample code for using
the DLL to read an .ldb file.
Microsoft provides programming examples for illustration only, without warranty
either expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes that you
are familiar with the programming language being demonstrated and the tools used to
create and debug procedures. Microsoft support professionals can help explain the functionality
of a particular procedure, but they will not modify these examples to provide added
functionality or construct procedures to meet your specific needs. If you have limited
programming experience, you may want to contact a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the
following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/overview/overview.asp
MORE INFORMATION
The dynamic link library Msldbusr.dll contains functions that enable you to
do the following:
- View all computers that have logged into a database since the .ldb file
was created.
- View only computers that are currently logged into a database.
- View computers that are causing a database file to be corrupted.
- View the count of computers logged into a database.
Msldbusr.dll is part of the Jetutils.exe file. For more information about
Jetutils.exe or Msldbusr.dll and its usage, please see the following
article in the Microsoft Knowledge Base:
Q176670
ACC: Microsoft Jet Utilities Available in Download Center
The following sample Visual Basic for Applications code calls the
LDBUser_GetUsers function of Msldbusr.dll to print a list of computers
currently connected to a database in the Debug window.
After installing Msldbusr.dll to the C:\Windows\System (Microsoft Windows
95) or C:\Winnt\System32 (Microsoft Windows NT) folder, follow these steps
to create and use the sample function:
- Create a new module in Microsoft Access 97
- Type or paste the following function declaration statement into the
Declarations section of the module:
Declare Function LDBUser_GetUsers Lib "MSLDBUSR.DLL" _
(lpszUserBuffer() As String, ByVal lpszFilename As String, _
ByVal nOptions As Long) As Integer
- Type or paste the following sample function into the module:
Public Function GetUsers(Optional StrDbPath As String)
ReDim lpszUserBuffer(1) As String
Dim intLooper As Integer
Dim Cusers As Long
Dim strMsgBox As String
On Error GoTo Err_GetUsers
' Check to see if a database path was passed
' to the function. If the argument was not used,
' assume that we're to investigate the .ldb
' of the current database.
If IsMissing(StrDbPath) Or StrDbPath = "" Then
StrDbPath = CurrentDb.Name
End If
' Set Cusers to the number of computers currently connected
' to the database. Insert computer information into the
' lpszUserBuffer array.
' Arguments of LdbUser_Get Users:
' 1 = All users who have logged in since the LDB file was
' created
' 2 = Only users who are currently logged in
' 4 = Only users who are causing the database file to be
' corrupted
' 8 = Just return the count of users
Cusers = LDBUser_GetUsers(lpszUserBuffer(), StrDbPath, 2)
' Print possible errors returned by the function.
Select Case Cusers
Case -1
strMsgBox = "Can't open the LDB file"
Case -2
strMsgBox = "No user connected"
Case -3
strMsgBox = "Can't Create an Array"
Case -4
strMsgBox = "Can't redimension array"
Case -5
strMsgBox = "Invalid argument passed"
Case -6
strMsgBox = "Memory allocation error"
Case -7
strMsgBox = "Bad index"
Case -8
strMsgBox = "Out of memory"
Case -9
strMsgBox = "Invalid Argument"
Case -10
strMsgBox = "LDB is suspected as corrupted"
Case -11
strMsgBox = "Invalid argument"
Case -12
strMsgBox = "Unable to read MDB file"
Case -13
strMsgBox = "Can't open the MDB file"
Case -14
strMsgBox = "Can't find the LDB file"
End Select
If Not IsEmpty(strMsgBox) And strMsgBox <> "" Then
MsgBox strMsgBox, vbCritical, "Error"
Exit Function
End If
' Print computer names to Debug window.
For intLooper = 0 To Cusers - 1
Debug.Print "User"; intLooper + 1; ":"; _
lpszUserBuffer(intLooper)
Next
Exit_GetUsers:
Exit Function
Err_GetUsers:
MsgBox Err.Description
Resume Exit_GetUsers
End Function
- To test this function, type the following line in the Debug window, and then press ENTER:
?getusers()
REFERENCES
For more information about Msldbusr.dll, review the Msldbusr.doc file found
in Jetutils.exe.
Additional query words:
inf locking
Keywords : kbdta AccCon KbVBA
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbhowto