Search code examples
c#asp.netsql-serverwinformsconnection-string

Getting error: A network-related or instance-specific error occurred while establishing a connection to SQL Server


I'm newbie developer. I have a problem trying to connect to SQL Server from my computer to server machine.

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)

I've searched the way to issue it and I'm found many solution. But none are working for me. Could you please help me?

This is my connection string

string constring = @"Data Source=137.xx.xx.xxx\\SQLEXPRESS;Initial Catalog=EDI_HR;User ID=sa;Password=1234;";

and

string constring = @"Data Source=CISXXXXXX\SQLEXPRESS;Initial Catalog=EDI_HR;User ID=sa;Password=1234;";

Finally, those are some of the references of a solution that don't work for me:


Solution

  • Try this:

    string constring = @"Data Source=137.xx.xx.xxx\\SQLEXPRESS;Initial Catalog=EDI_HR;Integrated Security =True";