MS Access 使用 Windows 用户名连接到 SQL Server
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
删除
Properties UserID
和Password
,并替换为值为true
的Integrated Security
。*可能是大写的
T
表示true
Remove the
Properties UserID
andPassword
, and replace withIntegrated Security
with a value oftrue
.*Might be a capital
T
fortrue