ASP. NET cannot connect to SQL Server

Source: Internet
Author: User

At work today, a colleague asked me to say that I couldn't connect to the database and reported an error. This is the background

Post the error first

A network-related or instance-specific error occurred while establishing a connection to SQL Server. the server was not found or was not accessible. verify that the Instance name is correct and that SQL server is configured to allow remote connections. (provider: Named Pipes provider, error: 40-cocould not open a connection to SQL Server)

You are familiar with it. When talking about this problem, you may first think of the following points:

1. All SQL Server services are started

2. The server is set to allow remote connection.

3. Enable the TCP/IP protocol and named pipes protocol in the network protocol of the SQL Server server.

4. Exceptions for setting port 1433 in the firewall

Maybe set remotedacenabled to true?

Well, that's all I can think.

 

Below is the connection string

Data Source = IP \ Instance name; initial catalog = db_name; persist Security info = true; user id = userid; Password = ******

Is it wrong? Right? This is true. But why can't it be connected.

She directly declares a string in the program, then assigns the above section to this string, and then creates a connection. Yes, the process is correct. But it cannot be connected.

 

I have done all the above points I have learned. The result is still not good. It will crash ......

1. All SQL Server services are started

All started

2. The server is set to allow remote connection.

Set to allow

3. Enable the TCP/IP protocol and named pipes protocol in the network protocol of the SQL Server server.

Enable all

4. Exceptions for setting port 1433 in the firewall

Telnet connection

 

After lunch, I was sunned out and came back to sleep. Woke up, wiped your eyes, and looked at the news !! Let's take a look at this string.

Data Source = IP \ Instance name; initial catalog = db_name; persist Security info = true; user id = userid; Password = ******

 

Her statement:String conn = "Data Source = IP \ Instance name; initial catalog = db_name; persist Security info = true; user id = userid; Password = ******";

You can see the slash. It's a swivel chair character... Tears ran away...

I added an AT in front and connected it...

 

This problem can be mentally retarded, but it just happens. A lot of people on the Internet say that this is the same, and that person is also set up to see if you have the same problem as I have encountered?

 

 

 

 

 

 

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.