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

Possible To View All Users Who Have A Database Open? 2

Status
Not open for further replies.

Spyder757

Technical User
Aug 29, 2002
129
0
0
US
I've got a database at work that at any time may have 10 to 15 people using it.

I would like to be able to view either the address of the machine on the network....

-OR-

The user ID used by the person to log into the work station. We run Windows NT 4.0, 2000, and a few machines have XP.

The Access is version 1997.

Any ideas? I've trid using "Currentuser" but it doesn't seem to work.

Spyder757
 
Hi,

Create a table, that you hide. With some code, at startup, add a record with the time and the use name. Query that table.



Jean-Paul
Montreal
jp@solutionsvba.com
mtljp2@sympatico.ca
 
A simple but dirty way to do this is to find the .ldb file for the backend database (or the database on the server that everyone accesses) file. Change the file extension to .doc then open the file in MSWord.

HTH,
Eric
 
Great!!
You get a star.

Jean-Paul
Montreal
jp@solutionsvba.com
mtljp2@sympatico.ca
 
Wow, that's pretty damn sweet.

Thanks.

Spyder757
 
Run this code to get the machine names of each user accessing the database. It displays the data in the Immediate Window so be sure to have that window displayed. Also, the code includes a reference to "C:\test.mdb", replace this path with the path to your target database. I like the solution mentioned above but it won't help if you want to find logged in users with code.

Code:
Sub ShowUserRosterMultipleUsers()
    Dim cn As New ADODB.Connection
    Dim cn2 As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim i, j As Long

    cn.Provider = "Microsoft.Jet.OLEDB.4.0"
    cn.Open "Data Source=c:\Northwind.mdb"

    cn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
    & "Data Source=c:\test.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
[/blue]
 
Also, the ".ldb" file may be (usually IS) not entirely correct. Since it is not intended as a User table, MS. doesn't actually delete (individual) entries when a user disconnects or closes the db, but simply marks it as an available entry and will reassign it to the next user to sign on, so while all of the current actual users are listed - there may be (usually ARE) some users shown who have disconnected.

I would also recommend NOT changing the extension of the ".ldb" file.



MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
you can also use the software Net Watch come with windows nt 4 server ressource kit. You can view all share folder on station and server, see all open files by all users. Manage Shares, stop share.
 
Check out thread705-639609 It describes a method for determining whos logged on to your database, broadcasting a message for them to exit, forcing their database to exit immediately, listing their names, phone numbers, etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top