error while connectivity with SQL server using ( web forms )

Mohammad Qasim 576 Reputation points


Giving below error, while connectivity with sql server using ( web forms )

attached is the image of error

below Error Details:

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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)'

How can i remove this error to make connectivity.


A set of technologies in the .NET Framework for building web applications and XML web services.
3,169 questions
0 comments No comments
{count} votes

Accepted answer
  1. XuDong Peng-MSFT 8,096 Reputation points Microsoft Vendor

    Hi @Mohammad Qasim ,

    According to your description, you seem to be trying to connect to the database locally. If this is the case, I think the most likely reason is that the Sqlserver service is not started or is not running as other community member mentioned.
    You could try to use window + R and type services.msc to view the status of Windows services, and find SQL SERVER with instance name. It is usually Sql Server (MSSQLSERVER). Start/Restart it will be ok.
    This problem may also be caused by other reasons, you could also refer to this similar case below to see more related solutions:
    “Cannot Connect to Server - A network-related or instance-specific error”?

    Best regards,
    Xudong Peng

    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

1 additional answer

Sort by: Most helpful
  1. Olaf Helper 38,861 Reputation points

    Is SQL Server service running? Can you connect to using SSMS or an other tool? Is the name of the server the right on?

    See MS Support: Solving Connectivity errors to SQL Server