error while connectivity with SQL server using asp.net ( web forms )

Mohammad Qasim 576 Reputation points
2021-05-03T09:25:15.127+00:00

Greetings,

Giving below error, while connectivity with sql server using asp.net ( 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.

Thanks

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

Accepted answer
  1. XuDong Peng-MSFT 10,341 Reputation points Microsoft Vendor
    2021-05-04T03:33:44.887+00:00

    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 43,246 Reputation points
    2021-05-03T10:29:23.267+00:00

    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