Access connect to SQL server with automatic VBA password entry?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to use VBA to automatically enter the logon and password to a SQL
server when I log on.
 
I need to use VBA to automatically enter the logon and password to a SQL
server when I log on.

Look at the Open() method of the ADODB.Connection object. You can pass it a
connection string like this, and optionally, a separate username and
password:

Provider=SQLOLEDB.1;Data Source=SqlServerComputerName;Initial
Catalog=DatabaseName;User ID=MyAccount;Password=MyPassword

Alternately, you can connect to SQL Server using "Windows Authentication"
which does not require a username/password, but borrows the credentials that
the user used to login to Windows:

Provider=SQLOLEDB.1;Data Source=SqlServerComputerName;Initial
Catalog=DatabaseName;Integrated Security=SSPI
--
Peace & happy computing,

Mike Labosh, MCSD

"It's 4:30 am. Do you know where your stack pointer is?"
 
Back
Top