1
votes

My "classic ASP" application is on Windows Server 2003 and uses ADO to connect to a SQL Server 2008 database.

The database server is being upgraded from a changing and will be running SQL Server 2017.

I am trying to prove that the old application can still work, connecting to this newer version of SQL Server.

I have so far not had success in making a connection to a SQL Server 2017 installation from the old WS2003 machine.

I am not sure what OLEDB or ODBC providers or drivers I need to install to get this to work, and ultimately, what the Connection String will need to be.

I have created a small demo program to make the connection using the same code as the real application will. Essentially, all I am doing here is providing a connection string and attempting to connect. This is VB6 using ADO:

Private Sub btnConnect_Click()

    Dim theConnection As New ADODB.Connection

    theConnection.ConnectionString = Text1.Text 
    theConnection.Open ConnectString

    If theConnection.State = 1 Then
        MsgBox ("connected ")
    Else
        MsgBox ("failed to connect ")
    End If

End Sub

I can get this program to run on the new server - the one with SQL Server 2017, and it connects successfully.

This connection string works :

Driver={SQL Server Native Client 11.0};Server=192.168.0.23;Database=TestDB;Uid=user1;Pwd=xxx;

This also works :

Driver={SQL Server};Server=192.168.0.23;Database=TestDB;Uid=user1;Pwd=xxx;

This one is the exact format that the existing code uses to connect.

Now, I understand that for ADO, I have not specified Provider, so I think it defaults to MSDASQL, Microsoft's OLEDB provider for ODBC.

So, to get this to connect from the WS2003 application server, is where I have problems. Is this going to be possible?

I have tried these connection strings with these results :

Driver={SQL Server};Server=<IP address of SQL2008 server>;Database=yyy;Uid=xxx;Pwd=xxx;

This WORKS - and this is the existing SQL2008 database.

Driver={SQL Server};Server=<IP address of SQL2017 server>;Database=TestDB;Uid=user1;Pwd=xxx; 

This takes approx 20-30 seconds to fail with this message :

[ODBC SQL SERVER DRIVER]SQL Server does not exist or access denied

Is the "old" {SQL Server} driver going to be able to connect to to SQL2017?

Driver={SQL Server Native Client 11.0};Server=192.168.0.23;Database=TestDB;Uid=user1;Pwd=user1;

This fails immediately with the message :

[ODBC Driver Manager]Data Source Name not found and no default driver specified

Does this mean that the {SQL Server Native Client 11.0} ODBC driver is not installed on the WS2003 machine? Can it be installed?

I have tried looking at the various ODBC driver installations from Microsoft here : https://docs.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-2017

However, I'm not sure if I need to be doing this or if they are compatible with WS2003.

Microsoft ODBC Driver 17 for SQL Server : requires at least Windows Server 2008 R2. Same for Microsoft ODBC Driver 13 and 11. I did get the version 11 to install, event though it probably is not supported. I did use this to successfully create a new ODBC data source to the old SQL2008 database, but not to the SQL2017 database.

What do I need to do to resolve this?

1

1 Answers

6
votes

ADO doesn't use "Drivers" that's ODBC terminology. It uses OleDb "Providers". There are three OleDb providers for SQL Sever (in addition to MSDASQL, the OleDb Provider for ODBC drivers which shouldn't be necessary for SQL Server, since it has native OleDb providers).

The old, SQLOLEDB provider has been included in Windows since Windows Server 2003, and it's probably the right one to connect from your old server. The current one is MSOLEDBSQL, and is available here, and should be used whenever possible instead of the old SQLOLEDB or the newer, but deprecated SQLNCLI provider.

Here's a VbScript that you can use to test connections from any Windows computer.

Wscript.Echo "SQLOLEDB"
set theConnection = createobject("ADODB.Connection")
theConnection.ConnectionString = "Provider=SQLOLEDB;Data Source=localhost;Integrated Security=SSPI"
theConnection.Open ConnectString

Wscript.Echo "SQLNCLI"
set theConnection = createobject("ADODB.Connection")
theConnection.ConnectionString = "Provider=SQLNCLI;Data Source=localhost;Integrated Security=SSPI"
theConnection.Open ConnectString

Wscript.Echo "MSOLEDBSQL"
set theConnection = createobject("ADODB.Connection")
theConnection.ConnectionString = "Provider=MSOLEDBSQL;Data Source=localhost;Integrated Security=SSPI"
theConnection.Open ConnectString

Save it to a .vbs file and run it with the command:

c:\test> cscript test.vbs