SQL Server connection string question

10,551

Solution 1

Copied from my answer on your question on ServerFault...

The connection strings have 2 differences so I'll try to answer for this...

  • Named instances do not listen on port 1433 (only the default instance by, er, default)
  • The instance name is ignored when the port is specified

So:

  • ServerName\InstanceName,1433 means connect to server "ServerName" on port 1433
  • ServerName\InstanceName means connect to server "ServerName" and resolve instance name to correct port (resolve uses port 1434 UDP)

However, network library=dbmssocn means use tcp. It could be the SQL Server instance (see port stuff) does not listen on tcp

Solution 2

At a guess the 2005 and 2008 instances would be listening on different ports. Perhaps you need to set the connection string for the SQL Server 2008 instance to the correct port; you could be hitting the SQL Server 2005 listener and asking it for an instance that is not present on the 2005 installation.

What port is the SQL Server 2008 instance listening on - This article discusses the subject. and has a powershell script that actually interrogates the system to find out what port the DBMS is really listening on. It also talks a little about where this config lives in the registry.

Share:
10,551
Tamir
Author by

Tamir

passionate coder, always after learning new stuff, never hesitate to step outside the comfort zone, productivity junky

Updated on June 04, 2022

Comments

  • Tamir
    Tamir almost 2 years

    I'm trying to connect to a named SQL instance on the server. There is already default instance of SQL Server 2005 and a newly named one - SQL Server 2008. I'm using the "Network library" property to use TCP connection but for some reason, he try's to connect the default instance and omit an error about login error.

    If I remove the network library propery the connection established as well without any error.

    I'm using windows authntication and have all the permissions needed.

    The problematic connection string:

    Data Source=ServerName\InstanceName,1433;network library=dbmssocn;Initial Catalog=MyDataBaseName;Integrated security=SSPI

    The working connection string:

    Data Source=ServerName\InstanceName;Initial Catalog=MyDataBaseName;Integrated security=SSPI

    Omitting the ,1433;network library=dbmssocn from the connection string makes the difference. adding it maked the server to connect the deafult instance. Both of the server allows remote connections.

    I would like to understand why, please. Thanks in advance,

    Tamir