0

So something very strange happened with this old C# application I started to work on. I copied it locally and I've been studying the codebase without making any changes. In fact, it ran locally every day for the past week. Again, no code changes or changing in the configuration, etc. Today, I wasn't able to run it anymore. I even cloned a fresh copy - no luck. Now it's giving me this error and I don't know why. The database is remote but I can see that it's working when RDPing. What could cause this?

public static SqlConnection OpenSqlConnection(dbConnections connection, string applicationName = null)
        {
            var conn = CreateSqlConnection(connection, applicationName);
            conn.Open();
            return conn;
        }

In this line, I get the following error:

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)'

zealous
  • 7,336
  • 4
  • 16
  • 36
  • Does this answer your question? [Why am I getting "Cannot Connect to Server - A network-related or instance-specific error"?](https://stackoverflow.com/questions/18060667/why-am-i-getting-cannot-connect-to-server-a-network-related-or-instance-speci) – Tom Joney Jul 16 '20 at 21:38
  • It doesn't. Thanks though – crytodactyl Jul 16 '20 at 21:42
  • What method are you using to connect, TCP, host names etc? Can you show your connection string (obviously remove any sensitive data!) – Charleh Jul 16 '20 at 21:56

1 Answers1

1

This Definitely looks like a network issue rather than anything to do with the code. Check if Your SQL Server is accessible over the network