0

i need to add a username and password to my ADODB connection

With cn
    .ConnectionString = "DRIVER={SQL Server}; " & _
    " SERVER=MyServerName;" & _
    " DATABASE=db;" & _
    " Trusted_connection=YES"
    .Open
End With

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
sun22
  • 29
  • 1
  • 6
  • 1
    uid for userid and pwd for password – Warcupine Jul 15 '19 at 12:28
  • reference here: https://stackoverflow.com/questions/34389720/connection-string-for-sql-server-2014-express-vba – Warcupine Jul 15 '19 at 12:29
  • 1
    @Warcupine Perhaps you should combine and expand those two comments into [an answer](https://stackoverflow.com/questions/57039748/how-to-add-username-password-to-connection-string-adodb#new-answer)? – Chronocidal Jul 15 '19 at 12:39

1 Answers1

1

This is a good resource to find possible connection strings: https://www.connectionstrings.com/sql-server/

You can try e.g.:

With cn
    .ConnectionString = "DRIVER={SQL Server}; " & _
    " SERVER=MyServerName;" & _
    " DATABASE=db;" & _
    " User Id=myUsername;" & _
    " Password=myPassword"
    .Open
End With
Łukasz Nojek
  • 1,511
  • 11
  • 17