Reputation: 311
Below is a ADODB for sql server connection. What would be the DAO equivalent for it? I tried using the same cs, but it keeps giving me error. I want to use DAO because there's lots existing code based on DAO, and based on what I see, certain functions aren't shared between DAO and ADODB. Trying to NOT reinvent the wheel here. Thanks all in advance.
ADODB:
dim cs as String
dim cn as Object
set cs = "Provider=MSOLEdbSQL;Integrated Security=SSPI;Initial Catalog=%DBInstanceName%;Data Source=%DBServer%;"
cn = CreateObject("ADODB.Connection")
cn.ConnectionString = cs
cn.Open (ConnectionString:=cs)
DAO: (error: ODBC--connection to ‘%DBServer%' failed)
dim cs as String
dim cn as Object
dim db as object
cn = CreateObject("DAO.DBEngine.36")
set db = cn.OpenDatabase("%DBServer%", False, False, “ODBC;Database=%DBInstanceName%;DSN=%DBServer%;Integrated Security=True")
Upvotes: 0
Views: 38