A client has for many years been using an Excel VBA application to interact with a SQL database. Recently the database has been upgraded from TLS 1.0 to TLS 1.2, which caused the connection from VBA to fail, as the SQLOLEDB driver has been deprecated. (Background here and here.)
To resolve the issue, I am trying to change the SQL driver from SQLOLEDB to MSOLEDBSQL. However, attempting to connect to the DB triggers run-time error 3706: "Provider cannot be found. It may not be properly installed."
Here is the relevant code:
Dim conn As ADODB.Connection
Dim sConnString As String
sConnString = "Provider=MSOLEDBSQL;" & _
"Data Source=MyServerName;" & _
"Initial Catalog=MyDBName;" & _
"User ID=SomeID;" & _
"Password=SomePassword;" & _
"DataTypeCompatibility=80"
Set conn = New ADODB.Connection
conn.Open sConnString
All instructions I have found online say to simply install the MSOLEDBSQL driver from Microsoft and change Provider=SQLOLEDB
to Provider=MSOLEDBSQL
in the code. But as I keep getting error 3706, presumably I must have missed a step.
Steps taken so far:
- Installed 32-bit MSOLEDBSQL driver from Microsoft.
- Confirmed that DLL files have been added to the default location, C:\Windows\System32.
- Restarted Windows.
- From the command line, ran
REGSVR32 "C:\Windows\System32\msoledbsql19.dll"
. Windows confirmed that the resource had been correctly registered. - In Visual Basic Editor, added a reference to Microsoft ActiveX Data Objects 6.1 Library (and removed a reference to the older v. 2.8 library).
Is it conceivable that the driver has not been properly installed, as claimed in the error description, when Windows also confirms that it has been correctly registered? How do I even troubleshoot this? Any thoughts on what is going on here?