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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to find out who's using the database?

Status
Not open for further replies.

JojoKa

Technical User
Mar 28, 2006
18
US
Hi,
We share a database. Is it possible to find out who's (the user) using it?
Thanks

Joseph
 
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
 
Yes,

You can read the ldb file that is created in the same path were the database is.
you can use this code. u Need to create a new module and paste this code and then create a form.



Option Compare Database
Option Explicit

Sub ShowUserRosterMultipleUsers()
Dim cn As New ADODB.Connection
Dim cn2 As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim rst As New ADODB.Recordset
Dim fcomp As String, flog As String, fcon As String
' Dim i, j As Long

cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open "Data Source=" & Application.CurrentProject.FullName

cn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Application.CurrentProject.FullName

' The user roster is exposed as a provider-specific schema rowset
' in the Jet 4 OLE DB provider. You have to use a GUID to
' reference the schema, as provider-specific schemas are not
' listed in ADO's type library for schema rowsets

Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
, "{947bb102-5d43-11d1-bdbf-00c04fb92675}")

'Output the list of all users in the current database.

DoCmd.OpenForm "frmShowUsers"
'Forms!frmShowUsers.label_users.Caption = rs.Fields(0).name & " " & rs.Fields(1).name & " " & rs.Fields(2).name & " " & rs.Fields(3).name & vbCrLf & vbCrLf
' Forms!frmShowUsers.label_users.Caption = Forms!frmShowUsers.label_users.Caption & " " & rs.Fields(0).name & " "
' Forms!frmShowUsers.label_users.Caption = Forms!frmShowUsers.label_users.Caption & " " & rs.Fields(1).name
' Forms!frmShowUsers.label_users.Caption = Forms!frmShowUsers.label_users.Caption & " " & rs.Fields(2).name
' Forms!frmShowUsers.label_users.Caption = Forms!frmShowUsers.label_users.Caption & " " & Nz(rs.Fields(3).name, "Null") & vbCrLf & vbCrLf


'Debug.Print rs.Fields(0).name, "", rs.Fields(1).name, _
"", rs.Fields(2).name, rs.Fields(3).name

'***************************************************************************************************************************
'****************************************************************************************************************************
'to able to display this information in a report save the info in a temporary table and then generate a report.

'****************************************************************************************************************************
'***************************************************************************************************************************
rst.Open "ShowUsers", CurrentProject.Connection, adOpenDynamic, adLockPessimistic

Do While Not rs.EOF
'Debug.Print rs.Fields(0), rs.Fields(1), _
rs.Fields(2), rs.Fields(3)
rst.AddNew
'Forms!frmShowUsers.label_users.Caption = Forms!frmShowUsers.label_users.Caption & " " & rs.Fields(0)
'Forms!frmShowUsers.label_users.Caption = Forms!frmShowUsers.label_users.Caption & " " & rs.Fields(1)
'Forms!frmShowUsers.label_users.Caption = Forms!frmShowUsers.label_users.Caption & " " & rs.Fields(2)
'Forms!frmShowUsers.label_users.Caption = Forms!frmShowUsers.label_users.Caption & " " & Nz(rs.Fields(3), "Null") & vbCrLf & vbCrLf
rst!computer = Left(rs.Fields(0), 20)
rst!LoginName = Left(rs.Fields(1), 20)
rst!Connected = rs.Fields(2)
rst!State = Left(rs.Fields(3), 10)
rst!Date = Date
rst.Update
fcomp = Left(rs.Fields(0), 20)
flog = Left(rs.Fields(1), 20)
fcon = rs.Fields(2)
Do While Left(rs.Fields(0), 20) = fcomp And Left(rs.Fields(1), 20) = flog And rs.Fields(2) = fcon And Not rs.EOF
rs.MoveNext
If Not rs.EOF Then
fcomp = Left(rs.Fields(0), 20)
flog = Left(rs.Fields(1), 20)
fcon = rs.Fields(2)
Else
Exit Do
End If
Loop
Loop
rst.close
rs.close
End Sub


 
Perfect. You guys are great.

Thanks

Joseph
 
Sub ShowUserRosterMultipleUsers()
Dim cn As New ADODB.Connection

Dim rs As New ADODB.Recordset
Dim i, j As Long

cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open "\\mccdc10a\S&A\OADMS\OADMS Tables\BE_OADMS.mdb"



' The user roster is exposed as a provider-specific schema rowset
' in the Jet 4 OLE DB provider. You have to use a GUID to
' reference the schema, as provider-specific schemas are not
' listed in ADO's type library for schema rowsets

Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
, "{947bb102-5d43-11d1-bdbf-00c04fb92675}")

'Output the list of all users in the current database.

Debug.Print rs.Fields(0).Name, "", rs.Fields(1).Name, _
"", rs.Fields(2).Name, rs.Fields(3).Name

While Not rs.EOF
Debug.Print rs.Fields(0), rs.Fields(1), _
rs.Fields(2), rs.Fields(3)
rs.MoveNext
Wend

End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top