I'm writing a code snippet in VBA to pull data from a SQL Server 2008r2 database. However, I'm getting a error at Conn.Open: [Microsoft][SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [53].
Using ConnectionString.com and another SO Question, I've written this:
Function GetAddress() As String
Dim Conn As ADODB.Connection
Set Conn = New ADODB.Connection
Dim Rst As ADODB.Recordset
Set Rst = New ADODB.Recordset
Conn.ConnectionString = "Provider=SQLNCLI10;Server=12.34.5678;" & _
"Database=OurDB;User ID=myuserid;Password=mypw;"
Conn.Open
Set Rst.ActiveConnection = Conn
Rst.Open "Select top 1000 * from MainTable"
End Function
Googling the error suggested that the Named Pipes might be Disabled. Following that lead, I checked the SQL Server Configuration Manager and Named Pipes are quite Enabled (3rd order behind Shared Memory and TCP/IP).
How do I make this error go away? Am I using the right connection string?