I have a database driven website written in asp.net. I'd like to modify the connection string to force protocol TCP. Please advise.
<add name="TESTConnectionString"
connectionString="Data Source=SERVER201;Initial Catalog=DB201;Persist Security Info=True;User ID=201User;Password=123!@#"
providerName="System.Data.SqlClient" />
You can force a protocol by adding the protocol in front of Server Name, e.g. use "tcp:myserver" as Server Name to connect to. Use "sm" for shared Memory (only local Connections) and "np" for named pipe.
Enable TCP/IP in the SQL ServerExpand the Configuration Tools subfolder and right-click on SQL Server Configuration Manager. Click on Run as Administrator. Select SQL Server Network Configuration and click Protocols for SMTKINGDOM. In the right pane, right-click TCP/IP and click Enable.
Solution: ODBC communicates with the SQL Server browser service using UDP port 1434 to detect the TCP port that SQL Server is using to communicate. ODBC then uses the detected port to communicate with SQL Server.
You can use server=tcp:hostname
in your connection string to achieve this.
For more details, see How to use the server name parameter in a connection string to specify the client network library
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With