Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forcing ASP.Net to use TCP/IP to connect to SQL Server instead of named pipes

How can I force my ASP.Net application to connect to a SQL Server using TCP/IP, not Named Pipes?

I read somewhere putting "tcp:" in front of the server name in the connectionstring should do the trick, but it does not seem to change anything.

Edit1:

  • TCP/IP is enabled on the SQL Server.
  • I tried Network Library=dbmssocn in the connectionstring, I still get an errormessage about named pipes: "provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server"

Edit2:

  • Turns out my problem was another hidden connectionstring used by entity framework
like image 955
Kjensen Avatar asked Jun 11 '09 20:06

Kjensen


People also ask

Should I enable Named Pipes in SQL Server?

In General, TCP/IP protocol is better in a slow LAN, WAN, or dial-up network. The Named Pipes protocol can be a better choice when the network speed is high, as it offers more functionality, easier to use, and have more configuration options.

How do I enable TCP IP connection in SQL Configuration Manager?

On the Start menu, click All Programs > Microsoft SQL Server 2012 > Configuration Tools > SQL Server Configuration Manager. Click SQL Server 2012 Services. Expand the SQL Server 2012 Network Configuration node, and then select Protocols for MSSQLServer (SQL Instance Name) . Right-click TCP/IP, and then click Enable.

Do Named Pipes use TCP?

Named pipes is a windows system for inter-process communication. In the case of SQL server, if the server is on the same machine as the client, then it is possible to use named pipes to tranfer the data, as opposed to TCP/IP.


1 Answers

You can force it in the connection string:

server=tcp:hostname

Via: http://weblogs.asp.net/jgalloway/archive/2007/02/24/sql-force-the-protocol-tcp-named-pipes-etc-in-your-connection-string.aspx

like image 51
Hardwareguy Avatar answered Oct 06 '22 22:10

Hardwareguy