07-04-2013, 02:10 PM
This is what I use and it works for me:
This assumes Windows Authentication so you do not need the username and password. If you need SQL authentication then you need to drop the Integrated Security=SSPI; Trusted_Connection=Yes" and put in your username and password.
Code:
objDB.ConnectionString = "Provider=SQLOLEDB; Data Source=MACHINENAME\INSTANCENAME; Initial Catalog=DATABASENAME; Integrated Security=SSPI; Trusted_Connection=Yes"
objDB.Open
This assumes Windows Authentication so you do not need the username and password. If you need SQL authentication then you need to drop the Integrated Security=SSPI; Trusted_Connection=Yes" and put in your username and password.