Link to home
Start Free TrialLog in
Avatar of Martin Barreda
Martin BarredaFlag for Argentina

asked on

MSAccess User List

Is there a way to list the user's accesing a MDB access database at a certain time?
1) i need the number of users
2) i need the name of that users
I need this, to ensure that backup operations and compact&repair operations, controlled by the application, can open in exclusive mode with share read/write deny. The name of the user tell me in wich PC is the application running (so get to it, and close the application).
I am using Delphi 7, embebed ADO components, Jet OleDB 4.
With user, i mean the name of the PC or the name of the user using the PC from where the application is running. There is nothing related to security in that word. Only the MDB has a password set, and the application set the connection with it.
MDB resides in a "server", and the other PCs access it from its unc path.
Avatar of FactorB
FactorB

- Make a table for users in MDB database and populate the users status (connected/disconnected) accordingly (do it with client app.) and also make a boolean field in the same table and name it something like "ForceDisconnect". Whenever the value is "Yes" the client program (checking periodically for the value, ex: every minute) disconnects and is unable to connect until the same field is populated with "No".

- Or when someone connects to the database there is a file created for every logged user ex: db.ldb, that resides in the same folder with the database. The same file disappears when there is no connection, except after database crushes.

- Here is how Microsoft recommends to determine who is logged on to a database by using Microsoft Jet UserRoster in Access
Access 2000 http://support.microsoft.com/?id=198755
Access 2002/2003 http://support.microsoft.com/?id=285822
Avatar of Martin Barreda

ASKER

Is one ldb file created for each user? or only one that carries out all info?
I like MS recommendations... do you know how to translate that to delphi, something using TAdoConnection.OpenSchema???
ASKER CERTIFIED SOLUTION
Avatar of FactorB
FactorB

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That's work!!! i make a little changes to adjust the function for me, and first i am getting only the number of users... not the names.
The mistake was to check for Fields[0].Name.... the name is in Value not Name...
Dispite that.... THANK YOU!!!
function  UsuariosConectadosADO(var acADOConnection: TADOConnection; ListaUsuarios: TStrings): integer;
var ADODataSet: TADODataSet;
begin
  Result := -1;
  ListaUsuarios.Clear;
  try
    ADODataSet := TADODataSet.Create(nil);
    if acADOConnection.Connected then
      begin
        acADOConnection.OpenSchema(siProviderSpecific,
                                   EmptyParam,
                                   '{947bb102-5d43-11d1-bdbf-00c04fb92675}',
                                   ADODataSet);
        with ADODataSet do
          begin
            First;
            repeat
              ListaUsuarios.Add(ADODataSet.Fields[0].Value);
              Next;
            until EOF;
          end;
      end;
    ADODataSet.Free;
    Result := ListaUsuarios.Count;
  except
    SysUtils.Abort;
  end;
end;

Open in new window

Sorry about that, I didn't had a time to compile it, I am glad that your code is working.
Regards,
B.