views:

209

answers:

3

I was adding a service-based database, but I got this message:

A network-related or instance-specific error occurred while establishing a connection to the 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 am an absolute beginner, so I have no idea how to fix this. I am following the book "O'Reilly Head First C Sharp Nov 2007" edition.

I am on page 18, it is asking me to add an SQL Database, in which I get that error message.

I'm a beginner programmer, so I don't know anything technical. I'm starting knowing nothing.

+2  A: 

Connections string issue. Check that. Otherwise it may be the allow remote connections property under the database properties. Right click on the database and select properties, then look at my image below.

alt text

Dustin Laine
+4  A: 

Aside from not allowing remote connections, there are a handful of other causes of this problem:

  1. The protocol being used (e.g. TCP/IP) isn't enabled. Go into the SQL Server Configuration Manager and ensure that the protocol you are using is enabled. E.g. if you are trying to use TCP/IP then TCP/IP must be enabled.

  2. A firewall, say on the SQL Server box itself, could be blocking traffic. If the Windows Firewall on that server is enabled you need to add an exception for port being used by the SQL Server instance (typically 1433).

  3. The port on which the SQL Server instance is listening (assuming a TCP/IP connection) isn't 1433. Go into the SQL Server configuration manager, into the TCP/IP protocol, to the IP Addresses tab and check the port.

Sometimes it isn't clear that you are actually connecting using the TCP/IP protocol if you are using a server name instead of a specific IP. In the connection string you can force the system to use TCP/IP by including Network Library=DBMSSOCN; like so:

<add name="MyConnectionName"
   providerName="System.Data.SqlClient"
   connectionString="Data Source=[Your Server Name];Network Library=DBMSSOCN;Initial Catalog=[Database Name];..."
   />
Thomas
A: 

This is the default error when a connection to a SQL server does not work, it could mean the server is down, network isn't routing, config is wrong, etc.

Jason Cumberland