MS Access 使用 Windows 用户名连接到 SQL Server

发布于 2025-01-05 21:35:15 字数 589 浏览 4 评论 0原文

Dim Cnxn As ADODB.Connection
Set Cnxn = New ADODB.Connection
With Cnxn
  .Provider = "MSDataShape"
  .Properties("Data Provider").Value = "SQLOLEDB"
  .Properties("Data Source").Value = dbserver
  .Properties("User ID").Value = Username
  .Properties("Password").Value = password
  .Properties("Initial Catalog").Value = dbname
  .CommandTimeout = 120
  .ConnectionTimeout = 120
  .Open
End With

上面是我如何从 MS Access 连接到 SQL Server,其中用户名是默认的 SQL 用户名。但是,我想使用 Windows 用户名进行连接,但没有时间在 SQL Server 上创建 100 个用户名(每个 Windows 用户一个)。有没有一个好的方法来做到这一点?这是出于审计目的,这样我就知道谁做了什么。

Dim Cnxn As ADODB.Connection
Set Cnxn = New ADODB.Connection
With Cnxn
  .Provider = "MSDataShape"
  .Properties("Data Provider").Value = "SQLOLEDB"
  .Properties("Data Source").Value = dbserver
  .Properties("User ID").Value = Username
  .Properties("Password").Value = password
  .Properties("Initial Catalog").Value = dbname
  .CommandTimeout = 120
  .ConnectionTimeout = 120
  .Open
End With

Above is how I connect from MS Access to SQL Server where username is a default SQL username. However, I would like to connect with the Windows username but don't have the time to create 100's of usernames on the SQL Server, one for each Windows user. Is there a nice way of doing this? This is for auditing purposes so I know who did what.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

徒留西风 2025-01-12 21:35:15

删除 Properties UserIDPassword,并替换为值为 trueIntegrated Security

.Properties("Integrated Security").Value = true

*可能是大写的 T 表示 true

Remove the Properties UserID and Password, and replace with Integrated Security with a value of true.

.Properties("Integrated Security").Value = true

*Might be a capital T for true

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文