Limit concurrent users

DCrake

Remembered
Local time
Today, 23:39
Joined
Jun 8, 2005
Messages
8,626
I have a VB app connected to a Access database, it has multi user access across a LAN. My question is is it possible to count the number of people currently using the app. I want to have many users but only allow 5 bums on seats at any one time.

Any Ideas.:cool:
 
Will if you "log in and out" of the database with connections... it should be easy...

Just create a table where you log usernames that are currently logged in... It is a simple matter of doing a select count(*) from table to fetch the number of current users.
Offcourse temporarily you would have 6 or even more to check if they are allowed in... but.... they are atleast not touching your " real " data.

Alternatively you could make a seperate database where your FE app logs in and out, where you count... thus keeping your data/BE free of this "extra" connections :)
 
Simple Software Solutions

I had that in mind when I was writing the thread, However I thought about using to lock file to test it. But as I already have a user table I might as well use that. Thanks anyway.:cool:
 
The lock file in the "newer" versions (IIRC 2002 and newer) are scrambled/unreadable as far as I know :(

It used to be (access 2) that you could retrieve your users from it... but no more (I think).
A seperate user table, in particular if you allready have one is a sure fire way of getting "things done" ;)

Good luck
 
a log in, log out thing is all well, but the users will muck it up when they control-alt-delete

you can write a function to check how many people are in the db:-

Code:
Function CountUsers(cn As ADODB.Connection)
    Dim rs          As ADODB.Recordset


    ' The user roster is exposed as a provider-specific schema rowset
    ' in the Jet 4.0 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}")

    CountUsers = 0
    With rs
        Do Until .EOF
            CountUsers = CountUsers + 1
            .MoveNext
        Loop
    End With
     
    rs.Close
    Set rs = Nothing


End Function

Sub test()
    Dim cn As ADODB.Connection
    Set cn = New ADODB.Connection
    ' Open the connection
    With cn
      .Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
         "Data Source=\\opssvr01\tpg_bo_data\EMTN\EMTN back end.mdb"
    End With
    
    MsgBox CountUsers(cn)
    
    Set cn = Nothing
   
End Sub

then when they log in, test for it and boot them out if the limit is exceeded
 
the LDB tells you who has logged in during the time it was created...you can open it in notepad, but it's not that useful in a multi user environment


hmm i'm not too sure that the currentproject connections aren't just read off the ldb anyway...
 
Last edited:
Simple Software Solutions

Thanks Darth added the snippet to my splash screen and it worked. Just one thing you have to deduct 1 from the record count as you become a connection as well. :cool:
 
Thanks Darth added the snippet to my splash screen and it worked. Just one thing you have to deduct 1 from the record count as you become a connection as well. :cool:

depends if you're in it

;)
 

Users who are viewing this thread

Back
Top Bottom