vba 如何找出当前正在使用 ms access 数据库的用户

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12091812/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 17:26:59  来源:igfitidea点击:

How do I find out which users are currently using an ms access database

databasevbausernamems-access-2010

提问by ben.watson.ca

I'd like to know if there is a way of finding out the user names of the people sharing a database with me.

我想知道是否有办法找出与我共享数据库的人的用户名。

I know that I can use the environ("UserName") call to get my own username but I'd like to know who else is in the database.

我知道我可以使用 environ("UserName") 调用来获取我自己的用户名,但我想知道数据库中还有谁。

回答by Fionnuala

This sample sub, which uses a provider-specific schema, will list users. You need to pass a valid connection, for example:

此示例子使用特定于提供程序的架构,将列出用户。您需要传递一个有效的连接,例如:

ADOUserList Currentproject.Connection

  Public Sub ADOUserList(oConn As ADODB.Connection)
  Dim rs As ADODB.Recordset
      Set rs = oConn.OpenSchema(adSchemaProviderSpecific, , _
          "{947bb102-5d43-11d1-bdbf-00c04fb92675}")
      Debug.Print rs.GetString
      rs.Close
  End Sub

The fields returned are:

返回的字段是:

COMPUTER_NAME
LOGIN_NAME
CONNECTED
SUSPECT_STATE