| There are 6 solution for error given above for connection cannot open.
(1)First Solution is to
(i)Open control panel.
(ii)And search for services.
(iii)Open Local services window from your search results
(iv)Restart your MSSQLSERVER service.
Below screen will be displayed
(2)Sirst Solution is to
Its a combination of 3 steps
(i)Enable Named Pipes SQL Config Manager --> SQL Server Network Consif --> Protocols --> Named Pipes --> Right-click --> Restart
(ii)Restart the server SQL Config Manager --> SQL Server Services --> SQL Server (SQLEXPRESS) --> Right-click --> Restart
(iii)Use proper server and instance names (both are needed!) Typically this would be .\SQLEXPRESS, for example see the screenshot from QueryExpress connection dialog.
(3)Third Solution is to
Below are some aspects which need to be checked
(i)Incorrect connection string, such as using SqlExpress
(ii)Named Pipes(NP) was not enabled on the SQL instance
(iii)Remote connection was not enabled
(iv)Server not started, or point to not a real server in your connection string
(v)Other reasons such as incorrect security context
(vi)try basic connectivity tests between the two machines you are working on
(4)Fourth Solution is to
Use below as connection string
connectionString="Data Source=localhost\InstanceName;Initial Catalog=DatabaseName;Integrated Security=True;" providerName="System.Data.SqlClient"
(5)Fifth Solution is to
(i)Select SQL Server Services from right.
(ii)Find your server from right and go to its properties (with right click)
(iii)Change log on method to Local System.
(6)Sixth Step is very simple
User Name should be (local)\SQLEXPRESS. | | |