0

I am trying to access a database I have recently developed remotely from another computer but on the same network. However, I always get the same error when trying to connect the database to the system built from C#:

System.Data.SqlClient.SqlException: 'Network-related or instance-specific error while establishing a connection to SQL Server. The server was not found or was not reachable. Check that the instance name is correct and that SQL Server is configured to support remote connections.

I am using the following code to access from the C# project (the IP is an example, it is not real):

private readonly string connectionString;
//Conexión a la base de datos del sistema en el servidor
public ConnectionToSql()
{
    connectionString = "Server=192.168.10.10;Database=CALIDAD_DB_KPI; integrated security= true";
}

//Obtener conexión de la base de datos del sistema
protected SqlConnection GetConnection()
{
    return new SqlConnection(connectionString);
Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
  • Does this answer your question? [Cannot Connect to Server - A network-related or instance-specific error](https://stackoverflow.com/questions/18060667/cannot-connect-to-server-a-network-related-or-instance-specific-error) – Thom A Mar 02 '23 at 16:54
  • That's not the real server ip is it? If so maybe you should obfuscate that in the question so people can't see it – JamesS Mar 02 '23 at 16:58
  • 1
    @JamesS It's a non-routable IP, so it's fine. Within a local network, SQL Server will actually do discovery by default, so it's not advertising anything SQL Server doesn't already advertise for itself. But yes, I wouldn't want to post a public IP that way for SQL Server. – Joel Coehoorn Mar 02 '23 at 17:02
  • Have you tested whether or not you can actually reach the remote server from your client (outside of .Net)? Have you pinged it? Have you attempted to connect using SSMS or a console? Please specify in your question, otherwise it's impossible to tell if this is a programming question or an IT/Network-related one! – Smolakian Mar 02 '23 at 17:07

0 Answers0