Users on an MS Access Database
Posted: 2003-06-01
By: ArchiveBot
Viewed: 82
Filed Under:
No attachments for this post
These Functions will allow you to determine WHO is logged on to the Acces Database as well as HOW MANY users are logged-in. As always the code is FREE, if you want support can consult me in my professional capacity. ENJOY
Original Author: Brian Gillham
Code
Public Function EmptyRS(ByVal oRS) As Boolean
On Error Resume Next
'Checks for an EMPTY RecordSet
EmptyRS = True
If Not oRS Is Nothing Then
EmptyRS = ((oRS.BOF = True) And (oRS.EOF = True))
End If
End Function
Public Function GetDBUsers() As ADODB.Recordset
' NOTES: Fields as follows
' 0 - COMPUTER_NAME: Workstation
' 1 - LOGIN_NAME: Name used to Login to DB
' 2 - CONNECTED: True if Lock in LDB File
' 3 - SUSPECTED_STATE: True if user has left database in a suspect state(else Null)
On Error GoTo LocalError
Const JET_SCHEMA_USERROSTER = "{947bb102-5d43-11d1-bdbf-00c04fb92675}"
' Return a Disconnected RecordSet
If cnADO.State = adStateOpen Then
Set GetDBUsers = cnADO.OpenSchema(adSchemaProviderSpecific, , JET_SCHEMA_USERROSTER)
Set GetDBUsers.ActiveConnection = Nothing
End If
LocalError:
End Function
Public Function GetDBUserCount() As Long
On Error GoTo LocalError
Dim lRS As ADODB.Recordset
Set lRS = GetDBUsers
If Not EmptyRS(lRS) Then
GetDBUserCount = lRS.RecordCount
lRS.Close
End If
LocalError:
Set lRS = Nothing
End Function
Comments on this post
No comments have been added for this post.
You must be logged in to make a comment.