Back to basics: the SQL Server network library specifiers in ADO.NET connection strings

Posted: (EET/GMT+2)

 

When developing applications with .NET and any of the ADO.NET related data access technologies (like Entity Framework), you need to work with connection strings.

In most cases today, you will want your C# application to access the SQL Server database using TCP/IP socket connections, but this is not always the optimal choice, nor it might be the default one supported by SQL Server.

In these situations, you need to know how to specify the required network connection type (the network library). This is done using the option "Network Library" in your connection string. For example:

Data Source=localhost;Initial Catalog=MyDatabase;Network Library=dbnmpntw;Integrated Security=SSPI;

Notice here the "Network Library" option which above has the value of "dbnmpntw". These values are somewhat cryptic and refer to pretty legacy versions of SQL Server. Nonetheless, the currently viable options in today's world are these two:

  • dbnmpntw: named pipes
  • dbmssocn: socket connection, i.e. TCP/IP, by default on port 1433

There are also legacy options for IPX/SPX and Vines networks, but in 2014, it's pretty rare you will ever need these. In case you are interested in history, check out this Microsoft KB article.

Hope this helps!