2012-02-13 40 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