当你的数据库为SQLEXPRESS时,在程序的数据库连接字符串的服务Server使用127.0.0.1\SQLEXPRESS时,如下:
它会显示一异常:
Server Error in '/' Application.
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: 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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
127.0.0.1只能使用默认实例名。如果你想连接非默认的数据库的话,即是说带有实例名的数据库时,那你得参考:
《The system cannot find the file specified》http://www.cnblogs.com/insus/p/5426975.html