C # Connection string database server port number

Source: Internet
Author: User
Tags mssql server port number server port

Normal database connection string configuration, which is the case where the MSSQL server port is 1433 (default).

<add key= "Article" value= "server=.; uid=admin;pwd=admin;database=db; " ></add>

But sometimes, for the database server to be secure, the port is changed to something else, and then connecting to the database may report the following error:

An error occurred while establishing a connection to the server. When you connect to SQL Server 2005, this failure may be caused by SQL Server not allowing remote connections under the default settings. (provider: Named pipe provider, error:40-cannot open a connection to SQL Server)

You just need to add the port number:

<add key= "Article" value= "server=., port slogan; uid=admin;pwd=admin;database=db;" ></add>

Port Modification Method:

"Start"--> "Server Network Utility"-->tcp/ip--> default port: 2433 (other can also)

StateServer Session Management

Set the Mode property to StateServer, which means that the session data is stored in a separate memory buffer, and then the Windows service running on a separate machine controls the buffer. The full name of the status service is "ASP.net State Services" (Aspnet_state.exe), which is configured by the stateConnectionString attribute in the Web.config file. This property specifies the server on which the service resides and the ports to monitor:

<sessionstate mode= "StateServer"

Stateconnectionstring= "tcpip=myserver:42424"

Cookieless= "false" timeout= "/>"

In this example, the State service runs on a 42424 port (the default port) of a machine named MyServer. To change ports on the server, edit the port value in the Hkey_local_machine\system\currentcontrolset\services\aspnet_state\parameters registry key. Obviously, the advantage of using state services is process isolation, which can be shared in the Web farm. With this mode, session state storage will not depend on the failure or restart of the IIS process, however, all session data will be lost once the status service is aborted. In other words, the State service does not persist data as SQL Server does; it simply stores the data in memory.

Unable to issue a session-state request to the session-state server. Make sure that the ASP.net state Service (asp.net) is started and that the client port is the same as the server port. If the server is on a remote computer, check

Hkey_local_machine\system\currentcontrolset\services\aspnet_state\parameters\allowremoteconnectio

N to ensure that the server accepts remote requests. If the server is located on the local computer and the registry value mentioned above does not exist or is set to 0 (if you accept a remote connection if you change to 1), the state server connection string must use "localhost" or "127.0.0.1" as the server name.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.