sql-servervb6oledbadodb

a *FUTUREPROOF* Project reference, to connect to SQL Server?


Background

i have legacy VB6 code that accesses SQL Server. it produces an error code 0x80004005 when TLS 1.0 is disabled for SQL Server, because the code still uses the provider SQLOLEDB:

[DBNETLIB][ConnectionOpen (SECDoClientHandshake()).]SSL Security error.

it does not explicitly use TLS, but TLS is always used for credentials according to Microsoft documentation.

Possible Solution

after looking around i have found that Microsoft released the new provider MSOLEDBSQL as a replacement for SQLOLEDB. MSOLEDBSQL supports TLS 1.2 and that will be kept updated, according to their documentation:

i've tested MSOLEDBSQL after installing the drivers, and changing the (ADODB.Connection) connection string from:

c.ConnectionString = "Provider=SQLOLEDB;Data Source=" & svr & ";Initial Catalog=" & db & ";User Id=" & u & ";Password=" & p & ";"

to:

c.ConnectionString = "Provider=MSOLEDBSQL;DataTypeCompatibility=80;Data Source=" & svr & ";Initial Catalog=" & db & ";User Id=" & u & ";Password=" & p & ";"

and this fixes the problem.

Questions

however, i'm not sure, that what i'm doing is futureproof.

i would prefer to change as little as possible


Solution

  • MDAC and the VB6 runtime are Windows components, and MSOLEDBSQL is current, and will continue to be maintained. So that is your best combination for running this legacy codebase now and in the future.

    Also SQLOLEDB was updated to support TLS 1.2. See Is sqloledb actually using MSOLEDBSQL on Windows Server 2019 So legacy codebases shouldn't be breaking on this any more.