This failure may occur if SQL server does not allow remote connection by default.

Source: Internet
Author: User
Tags microsoft sql server 2005 mssqlserver

An error occurred while establishing a connection with the server. When you connect to SQL Server 2005, the default setting does not allow remote connection to SQL Server may cause this failure. (Provider: named pipeline providesProgram, Error: 40-unable to open the connection to SQL Server)

Solution (from network ):

The preceding error occurs in two cases: one is when SQL Server 2005 is enabled, and the other is when the application connects to SQL Server 2005. we have summarized the following reasons:

1. The database engine is not started.

There are two startup methods:

(1) Start-> Program-> Microsoft SQL Server 2005-> SQL Server 2005 peripheral application configurator. On the displayed page, click "peripheral application configurator for service connection ", on the displayed page, find the database engine and click "service". Check whether the service is started on the right side. If not, click "start" and make sure "Start type" is automatic, do not manually start the instance. Otherwise, the instance must be manually started the next time it is started;

(2) You can choose Start> program Microsoft SQL Server 2005> Configuration tool> SQL Server Configuration Manager, and select SQL Server (MSSQLServer) in SQL Server 2005 ), click "Start Service" in the toolbar to change the service status to start;

When using the above two methods, sometimes an error may occur during startup, and cannot be started, in this case, check whether the Via in SQL Server 2005 network configuration> MSSQLServer protocol is enabled in "SQL Server 2005 Configuration Manager". If yes, disable it. then, execute the preceding operation.

2. Whether remote connection is allowed during remote connection.

By default, SQL Server 2005 only supports local connections. you can manually enable remote connection. in the first method above, find the database engine, click "remote connection", and change "local connection only (l)" to "local connection and remote connection (r)" on the right )", select "use TCP/IP and named pipes (B) at the same time )".

3. For a remote connection, check whether the database connection statement is correct, the Logon account is correct, and the password is correct.

When I connect to a database in a LAN, it is necessary to have a problem because of the connection string. When one machine is connected to another machine in the LAN, set Server = IP address of another machine with database installed. I always encountered the above error when connecting to the database. After checking for a long time, I found that the IP address was not correctly transmitted to the connection string. In the past, I used a local connection, that is, 127.0.0.1, the input IP address is not passed to the connection string.

Usage tips:

Because when I first installed server2005, I set it to window login verification. Later, I tried many ways and didn't change it. Finally, I realized it with the help of a netizen, however, when using SA and password in Vs, the old man reported the above error. No way, he had to be able to locate the problem on the network. The method was similar to the one above. I did it one by one on the Internet, I was so impatient that I couldn't help it. I restarted my computer and didn't expect to try again. I don't want to report any more errors. Sun TMD, Microsoft, cannot help me. Sometimes you do exactly what you want, but the result is not what you want. At this time, you can change your mind. For example, you may restart your computer. Haha. Some software errors are inexplicable. I couldn't change everything I said at the time. I tried it again the next day. It was so strange ~

My SQL statement is:

Data Source = yonggesong \ sqlexpress; initial catalog = hrmanager; user id = sa; Password = 123

Related Article

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.