简体   繁体   中英

Connect password protected file

I want to connect with password protected access. Please advise as where can I pass the parameter for password in below coding.

With Acon1
    .Provider = "Microsoft.ACE.OLEDB.12.0"
    .ConnectionString = "Data Source=" + ThisWorkbook.Sheets(1).Range("V24").Value
    .Open
End With

With Rs1
    .CursorLocation = adUseClient
    .CursorType = adOpenDynamic
    .LockType = adLockOptimistic
    .ActiveConnection = Acon1
    .Source = "Select * from Headcount where [Employee ID]=" & myvalue0l
    .Open
End With

Try:

With Acon1
    .Provider = "Microsoft.ACE.OLEDB.12.0"
    .ConnectionString = "Data Source=" + ThisWorkbook.Sheets(1).Range("V24").Value & _ 
";User ID=admin;Password=" 'Password
    .Open
End With

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM