VB6 application ado connection for TLS1.2

user2812743 picture user2812743 · Mar 31, 2017 · Viewed 7.5k times · Source

I have to support a VB6 application that is still in production (ugh). A customer is specifying our software needs to be PCI compliant which requires TLS 1.2.

Anyone know how to do this?

I am using SQL Server 2014. I'm patched to build 12.0.4502.0.

Public Function GetConnection() As ADODB.Connection
  Dim con As ADODB.Connection

  On Error Resume Next
  Set con = New ADODB.Connection
  con.ConnectionTimeout = 10

  Dim connstring As String
  'connstring = "Provider=SQLOLEDB;Server=" & gstrServer & ";Database=" & gstrDB & ";User Id=" & gstrUser & ";Password=" & gstrPwd
  connstring = "Provider=MSDASQL;DRIVER=Sql Server;Server=" & gstrServer & ";Database=" & gstrDB & ";UID=" & gstrUser & ";PWD=" & gstrPwd

  con.Open connstring

  If Err Then Set con = Nothing
  Set GetConnection = con
End Function

The project is referencing "Microsoft ADO Ext. 6.0 for DDL and Security" and "Microsoft ActiveX Data Objects 2.5 Library"

I have tried multiple connection string options.

Thanks!

Answer

user2812743 picture user2812743 · Apr 6, 2017

I found the answer in Using ADO with SQL Server Native Client.

To enable the usage of SQL Server Native Client, ADO applications will need to implement the following keywords in their connection strings:

Provider=SQLNCLI11

DataTypeCompatibility=80

The following is an example of establishing an ADO connection string that is fully enabled to work with SQL Server Native Client, including the enabling of the MARS feature:

 Dim con As New ADODB.Connection

 con.ConnectionString = "Provider=SQLNCLI11;" _  
         & "Server=(local);" _  
         & "Database=AdventureWorks;" _   
         & "Integrated Security=SSPI;" _  
         & "DataTypeCompatibility=80;" _  
         & "MARS Connection=True;"   
con.Open

Changing the provider to SQLNCLI11 and adding DataTypeCompatibility=80 worked.