Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I find out who's in a database?

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
How can I find out who's in a database?
I don't have any users set up or anything.


DougP, MCP, A+
 
You can check out the ldb file, I include a function below, but simply opening it in a text editor will who is in the database.

I cannot credit this function as, yet again, I fogot to note the author. It may well be Microsoft.

Code:
Declare Function LDBUser_GetUsers Lib "MSLDBUSR.DLL" _
      (lpszUserBuffer() As String, ByVal lpszFilename As String, _
      ByVal nOptions As Long) As Integer

      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

 
What references need to be included for this?

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
I found that it would only run on a new database if the database was closed after creation and re-opened. The references were the normal references for a new Access 2000 database, that is:

Visual Basic for Applications
Microsoft Access 9.0 Object Library
OLE Automation
Microsoft ActiveX Data Objects 2.1 Library

You can get MSLDBUSR.DLL from:
 
You may also do a google search for ldbviewer

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I found another post that is using LDBView.exe
That works great.

DougP, MCP, A+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top