2012-02-13 61 views
2
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个用户名,每个用户都有一个用户名。有没有这样做的好方法?这是为了审计目的,所以我知道谁做了什么。的MS Access使用Windows帐号连接到SQL Server

回答

3

删除Properties UserIDPassword,并替换为Integrated Security,其值为true

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

*可能是一个资本Ttrue

+0

,并确保数据库服务器知道登录或更好的仍然是一个组的用户是上午成员。 – 2012-02-13 15:06:54