I get the following error when trying to connect to SQL Server:
Cannot connect to 108.163.224.173.
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 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 1326)
This error is thrown when I try to configure my database to gridview in Visual Studio 2010. I'm at a loss as to how to debug this error.
How would you debug this error? What steps should I take in order to determine what is really going on here, in addition to the one mentioned in the error message?
Adding my heavily upvoted comment as an answer with screenshots.
I spent a lot of time on this, finally what worked for me is:
1) Open Sql Server Configuration Manager --> SQL Server Network configuration --> Protocols for <(INSTANCE)> --> TCP/IP (double click on it).
2) Select --> IP Addresses(Tab).
3) Go to the last entry IP All and mention TCP Port 1433.
4) Press Win+R and enter services.msc.
5) Now restart SQL Server <(INSTANCE)>.
After this, the problem got resolved!
You may check service status of MS SQL Server 2014. In Windows 7 you can do that by:
While the above solutions should work in 90% of the cases, but if you are still reading this answer!!! You are probably trying to connect to a different server than intended. It may be due to a configuration file pointing to a different SQL server than the actual server you think you are trying to connecting to.
Happened to me atleast.
If you suddenly encounter this error say in a production environment and nothing has changed, try the following 4 items in the order below to see if it gets fixed.
My issue started when I tried to change the server from IIS Express to Local IIS (while using LocalDB).
I was using LocalDB (for dev purposes), and when I went to revert from Local IIS to IIS Express, Visual Studio had switched my data source from Data Source=(LocalDb)\MSSQLLocalDB to Data Source=.\SQLEXPRESS
Incorrect connection string
<add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\SurveyTestsDB.mdf;Initial Catalog=SurveyTestsDB;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
Correct connection string
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\SurveyTestsDB.mdf;Initial Catalog=SurveyTestsDB;Integrated Security=True" providerName="System.Data.SqlClient" />
Hope this helps someone out there.
My issue was that you need to have a connection string entry in both your repository layer and web layer. Once I added it to my web.config as well as my app.config, Entity Framework was able to create the migration.
My question is why, does the web.config need it, when there is absolutely no database access there.