13

I'm having trouble connecting to a freshly installed instance of SQL Server 2014 Express. I'm not even totally sure what information you would need to help, so please bear with me as I'm very much an amateur. If I can provide anymore information to help, I'd be glad to.

The error I get is always the same,

"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)"

The server currently running SQL Server 2014 Express is Windows Server 2008 R2, with all patches sent out by Microsoft. This is a personal server at my home, so I can do whatever needs to be done with it to make this work.

To connect, I've tried using Visual Studio Community 2013, as well as the System.Data.SqlClient namespace in C# and in PowerShell.

I've made sure it isn't the firewall causing the problem. I set the rules properly, and when it still didn't work, I turned the firewall off completely. Same issue, no connection.

Here are a few examples of connection strings I've tried in .NET. I've removed the server, instance, userid, and password from these strings, and I'm sure I have those correct

Data Source=SERVERNAME\INSTANCENAME;Initial Catalog=Requests;Integrated Security=False;User ID=USERID;Password=PASSWORD

Data Source=SERVERNAME;Initial Catalog=Requests;Integrated Security=False;User ID=USERID;Password=PASSWORD

Server=SERVERNAME\INSTANCENAME; Database=DATABASE; User ID=USERID; Password=PASSWORD

Server=SERVERNAME; Database=DATABASE; User ID=USERID; Password=PASSWORD

If anyone has the time and patience to help a newbie sort this out, I'd really appreciate it. I'm using this setup to teach myself some SQL and ASP.NET MVC 5 development, and having a minilab at home would be awesome.

Thank you for your time.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Chris Martin
  • 383
  • 1
  • 3
  • 8

4 Answers4

23

First off, open services.msc and scroll down to SQL Server, and ensure its started.

If its not running modify to start automatically, and then start it.

Once it's running, close services panel, and run ssms.exe (management studio) and try connecting to Server Name: <machinename> or Server Name: <machinename\sql2014> [no <>]. You can also click the Server Name drop down list, and select BROWSE to see if your instance is listed - although I find this hit and miss.

Once you confirm its active and you are connected, follow this msdn page and follow the steps to enable tcp/ip connections.

From there you should have the details necessary to alter your connection string.

Dave C
  • 7,272
  • 1
  • 19
  • 30
  • 2
    This did it. Thank you sir/maam! – Chris Martin Aug 06 '15 at 20:56
  • You're welcome. What was the issue, so others can learn from this post? – Dave C Aug 06 '15 at 21:08
  • I didn't have TCP/IP enabled. Once I did that the connection opened wide up. – Chris Martin Aug 06 '15 at 21:12
  • 2
    After having a similar problem, I found in services.msc, the SQL Server service was set to "automatic" but for some reason was not "running". So starting the SQL Server service resolved this for me. – Peter Dec 14 '15 at 09:31
  • For me, it was the SQL Server Agent () that was disabled. Once I double clicked it, changed it to start automatically and then started it, I could then connect through Visual Studios! – SMKS Apr 13 '16 at 16:15
  • Thanks so much, it was that it wasn't running. Any clue as to why it would stop in the first place? – NocFenix Jun 02 '16 at 13:05
  • Tough to say.. If it's not set to start automatically in services, I'd check your application event logs for errors. – Dave C Jun 02 '16 at 20:31
2

SQL Server Express does not have TCP/IP connections enabled by default, instead it uses Shared Memory which means that external/remote connections from another computer won't work.

Open SQL Server Configuration Manager (it's on your Start Menu) and choose Server configuration and enable TCP/IP. Also open the properties for TCP/IP and ensure you have both "Active" and "Enabled" set to True on the bindings you want to use.

Dai
  • 141,631
  • 28
  • 261
  • 374
0

I had a similar issue with a C# connection string that was no longer working after we migrated from SQL Server 2008 R2 on a Windows 2008 R2 Server to SQL Server 2014 on a Windows 2012 R2 Server.

I opened SQL Server Configuration Manager and Enabled Named Pipes, restarted the SQL Server and all was right with the world (at least for a few minutes!)

Danimal111
  • 1,976
  • 25
  • 31
0

Make sure that your username and password are correct in case of Server Authentication mode. Go to Sqlserver Management Configuration and start SQL server services if any are in stop mode. enter image description here

Michael H.
  • 3,323
  • 2
  • 23
  • 31