Error: 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)
If you encounter above error, while running your VS.Net, than first thing you should do is to check your web.config file to make sure that connection string is correct.
This problem might occur if you have recently
- Change your PC Name
- Installed new sql server instance but have not updated your web.config file with correct instance name.
Example:
Earlier you were using instance name "YourPCName\SQLExpress" but due to new sql server instance installation your instance name changed to "YourPCName\CustomInstanceName".
Below is sample connection string, where text in red is cause of problem.
Data Source=MyPCName\MySQLInstance;Initial Catalog=MyDBName;Integrated Security=True
Solution
Check Connection string in your vs.net solutions, web.config file and correct with new sql server instance name.