SQL Server - sql error 26? - Asked By shanmugam on 03-Feb-11 04:41 AM

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)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection

Reena Jain replied to shanmugam on 03-Feb-11 05:00 AM
hi,

Solution:

  • Make sure SQL SERVER is up and the instance you try to connect is running.
  • Your system Firewall should not block SQL Server port.
  • Go to Computer Management >> Service and Application >> SQL Server 2005 Configuration >> Network Configuration
  • Enable TCP/IP protocol. Make sure that SQL SERVER port is by Default 1433.
  • Now follow this KB Article of MSDN depending on your server :http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277
Note: In order to get things to work. You might need to completely reboot the server machine after making the changes. There have been reports  that starting and stopping the SQL Server and Browser software is not enough.

hope this will help you
Anoop S replied to shanmugam on 03-Feb-11 05:56 AM
In Your connection string would look like:

<connectionStrings>
    <add name="myConnectionString";Integrated Security=true
       connectionString="Data Source=DB1\SQLExpress; database=Northwind;" />
</connectionStrings>

The connection string can be found in your web configuration file. (web.config)

Check if the connection string is alright.
a) You could have misspelt one of the attributes in the connection string. The servername in the above example is DB1 and the instance name is SQLExpress. Check if you have provided them alright.

b)  first, check if you have connectivity to the db server from the web server. You can try the age-old ping command from the command prompt or commands like Tracert. Again, consult your network administrator for faster help.

c)Do you have any firewall in between the web server and the database. If yes, check if you can let this call go thru. You will have to talk to your network administrator to get this done.

d)Make sure the SQL Server Browser service is running on the system.
 
e) Check if the remote connections are configured in SQL Server.  The entire steps are outlined in the Microsoft KB article that is located here. It explains how to create an exception in firewall in order to allow remote connections.
Rohan Dave replied to shanmugam on 03-Feb-11 06:43 AM
Just make sure you have selected Using both TCP/IP and named pipes option under Local and Remote Connection..

Follow the below steps :

Step 1 - Go to Start -> Programs -> Microsoft Sql Server 2005 -> Configuration Tools -> click on Sql Server Surface Area Configuration. It will show you below dialog box.



Step 2 - Click on Surfave Area Configuration for Services and Connections option. It will show you below dialog box and change you setting as per the below screen shot..