Cannot establish connection to SQL Server

user990635 picture user990635 · Dec 6, 2011 · Viewed 11.7k times · Source

I am trying to access SQL DB that is located on my computer from an application that is located on a server (has IIS7).
I set the ConnectionString in the WebConfig with the IP of my computer and I always get this 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

I wanted to enable remote connections as it was mentioned in the error. These are the things that I tried in order to make it work:

  1. Made sure that "Allow remote connections" to this server is checked in the properties window of my server
  2. Enabled TCP/IP in the SQL Server Configuration Manager
  3. Right clicking on the TCP/IP and in "Properties" set the port to 1433 and removed the "0" in the Dynamic Ports
  4. Created a new rule in the Windows Firewall to allow the connection from port 1433
  5. Added sqlservr.exe from the MSSQL/Binn folder to "Allow a program through Windows Firewall"
  6. Restarted the service

None of it helped. What else can I do?

EDIT:
Connection string:

<connectionStrings>
    <add name="someName" connectionString="Database=someDB;Server=<my computer's IP>;User=userName;Password=123" providerName="System.Data.SqlClient"/>
</connectionStrings>

Answer

Niranjan Singh picture Niranjan Singh · Dec 6, 2011

I am showing SQL Express setting this should be same in standard and other versions. check this and follow the first link for connection specification and testing for this problem.

enter image description here

Check these links for checking error exists regarding this particular topic and fixing this:
Resolving “A network-related or instance-specific error"
SQLAuthority- could not open connection