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?