SQL Server 2005/2008
When the open () method is called in C # code when the database connection is opened (account is SA), an exception occurs: The exception information is as follows:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or could not be accessed. Verify that your instance name is correct and
And SQL Server is configured to allow remote connections. (Provider:sql network interface, error:26-error locating the specified server/instance)
Win7 system solutions are as follows:
1. Open SQL Server Management Configurator
or enter at the command line: sqlservermanager10.msc
2. Click on the MSSQLSERVER protocol and select the TCP/IP protocol on the right page.
3, right click on the TCP/IP protocol, select "Properties", you need to modify the port address of the connection database
4, jump out of the dialog box, there are many TCP/IP ports, find "IP3", change the IP address for their own computer's IP address (or 127.0.0.1) on the TCP port add 1433, and then click Apply
5, modify the "IPALL" all the ports to "1433" (or this interface, pull down the scroll bar)
6. Restart the service
7, through the above 1-6 steps to set up a good port, reopen SQL Server Management Studio, the server name input: (local) or 127.0.0.1, you can log into the database.
Win XP system (may not have IP3) ibid.
NOTE: When SQL Server has multiple instances, be aware that TCP ports are not repeatable.
SQL Server Connection exception