11
 TITLE: Connect to Server
------------------------------

Cannot connect to Thejus-PC.

------------------------------ ADDITIONAL INFORMATION:

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)
> (.Net SqlClient Data Provider)
> 
> ------------------------------ For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=2&LinkId=20476
> 
> ------------------------------ Error Number: 2 Severity: 20 State: 0
> 
> 
> ------------------------------ Program Location:
> 
>    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
> exception, Boolean breakConnection, Action`1 wrapCloseInAction)    at
> System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
> stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)    at
> System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo,
> SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout,
> Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean
> integratedSecurity, Boolean withFailover, SqlAuthenticationMethod
> authType)    at
> System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo
> serverInfo, String newPassword, SecureString newSecurePassword,
> Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean
> withFailover)    at
> System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo
> serverInfo, String newPassword, SecureString newSecurePassword,
> Boolean redirectedUserInstance, SqlConnectionString connectionOptions,
> SqlCredential credential, TimeoutTimer timeout)    at
> System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer
> timeout, SqlConnectionString connectionOptions, SqlCredential
> credential, String newPassword, SecureString newSecurePassword,
> Boolean redirectedUserInstance)    at
> System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
> identity, SqlConnectionString connectionOptions, SqlCredential
> credential, Object providerInfo, String newPassword, SecureString
> newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString
> userConnectionOptions, SessionData reconnectSessionData,
> DbConnectionPool pool, String accessToken)    at
> System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
> options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo,
> DbConnectionPool pool, DbConnection owningConnection,
> DbConnectionOptions userOptions)    at
> System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection
> owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions
> userOptions)    at
> System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
> owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions
> userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
> connection)    at
> System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
> outerConnection, DbConnectionFactory connectionFactory,
> TaskCompletionSource`1 retry, DbConnectionOptions userOptions)    at
> System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
> outerConnection, DbConnectionFactory connectionFactory,
> TaskCompletionSource`1 retry, DbConnectionOptions userOptions)    at
> System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1
> retry)    at
> System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1
> retry)    at System.Data.SqlClient.SqlConnection.Open()    at
> Microsoft.SqlServer.Management.SqlStudio.Explorer.ObjectExplorerService.ValidateConnection(UIConnectionInfo
> ci, IServerType server)    at
> Microsoft.SqlServer.Management.UI.ConnectionDlg.Connector.ConnectionThreadUser()
> 
> ===================================
> 
> The system cannot find the file specified
halfer
  • 19,824
  • 17
  • 99
  • 186
thejustv
  • 2,009
  • 26
  • 42
  • Is SQL server started successfully? Well, Windows 10 is very new (just few days from official release), many interesting things might happen. – Raptor Jul 31 '15 at 02:39
  • 1
    It may also be important to know what *version* and *edition* of SQL Server you're using. Some older versions may not be officially supported on Windows 10. – Damien_The_Unbeliever Jul 31 '15 at 06:56
  • Its resolved.Actually the server service not starting even startup Type is automatic.I started manually and its working perfectly now. – thejustv Aug 01 '15 at 17:47
  • Thanks so much for this question. I couldn't use my DB for one year due to this very issue – Failed Scientist Apr 29 '16 at 00:40

4 Answers4

8

Please verify that Service "SQL Server (MSSQLSERVER)" is started.

I started the "SQL Server (MSSQLSERVER)" service and now i am able get into Sql server.

thejustv
  • 2,009
  • 26
  • 42
  • If this is the answer to your problem, then mark this answer as "answered" so future users know this solved the problem. – Johnathon Sullinger Aug 01 '15 at 17:49
  • 3
    This is the correct answer, but after upgrading SQL server service needs a manual start after every reboot. If anyone knows of a proper fix to this then please comment or answer. – David Kirkland Aug 17 '15 at 00:46
  • try to change the startup type to manual and try one.I changed to manual and now its automatically starting when we open SSMS – thejustv Aug 17 '15 at 10:42
  • 1
    @DavidKirkland Right click the service in task manager. Click ´Open services´. Find the service in the list and then double-click. Choose ´Automatic´ for start-up option. – serdar Aug 27 '15 at 19:13
  • 6
    @serdar Thanks for the advice. The service is set for auto start, but since the upgrade to Win10 it is failing to start when Windows starts. If I start it manually it works, but I don't want to do this after each reboot. I've just set the services for delayed start, and I'll see if this works after the next reboot... – David Kirkland Aug 28 '15 at 03:16
5

Please verify that Service "SQL Server (MSSQLSERVER)" is started. Just now I upgraded to Windows 10 and got the same issue.

I started the "SQL Server (MSSQLSERVER)" service and now I am able get into Sql server.

halfer
  • 19,824
  • 17
  • 99
  • 186
Ramakrishnankt
  • 131
  • 1
  • 3
1

We have encountered this problem with Windows 7 and Windows 8. After the upgrade SQL Server does not start. We have been able to start it manually, but it will not start automatically.

So far our only solution has been to uninstall and reinstall SQL Server.

Dan
  • 11
  • 1
0

Try changing your connection string to IP/NameInstance, it works for me. Before I used to have localhost/NameInstance in my connection string but since I updated to windows 10, it did not work anymore.