I get the following error when trying to connect to SQL Server:
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)
This error is thrown when I try to configure my database to gridview in Visual Studio 2010. I'm at a loss as to how to debug this error.
How would you debug this error? What steps should I take in order to determine what is really going on here, in addition to the one mentioned in the error message?
normally means that there is no MySQL server running on the system or that you are using an incorrect Unix socket file name or TCP/IP port number when trying to connect to the server. You should also check that the TCP/IP port you are using has not been blocked by a firewall or port blocking service.
To fix this problem, the ODBC Driver settings need to be adjusted. Follow these steps: Click Start > Settings >Control Panel > Administrative Tools > Data Sources (ODBC). Click the "System DSN" tab in the ODBC Data Source Administrator Window.
Check to see if allow remote connections for this server is enabled. In SSMS, right click on the instance name and select Properties. Go to the Connections tab and make sure Allow remote connections to this server is checked. If you need to make a change, you must restart the SQL Server instance to apply the change.
I found the following techniques helpful:
Make sure your database engine is configured to accept remote connections:
- Start > All Programs > SQL Server 2005 > Configuration Tools > SQL Server Surface Area Configuration
- Click on Surface Area Configuration for Services and Connections
- Select the instance that is having a problem > Database Engine > Remote Connections
- Enable local and remote connections
- Restart instance
You may need to create an exception on the firewall for the SQL Server instance and port you are using:
- Start > Run > Firewall.cpl
- Click on exceptions tab
- Add sqlservr.exe (typically located in
C:\Program Files (x86)\Microsoft SQL Server\MSSQL.x\MSSQL\Bin
, check your installs for the actual folder path) and port (default is1433
)- Check your connection string as well
Check if your SQL server services is up and running properly:
- Go to All Programs > Microsoft SQL Server 2008 > Configuration Tools > SQL Server Configuration Manager > SQL Server Services
- Check to make sure SQL Server service status is Running.
In addition, ensure that your remote server is in the same network. Run
sqlcmd -L
to ascertain if your server is included in your network list.
Enable TCP/IP in SQL Server Configuration
When two or more SQL Servers are connected across network they do all communication using TCP/IP. The default port of SQL Server installation is 1433. This port can be changed through SQL Server Configuration Manager. TCP/IP should be enabled for SQL Server to be connected.
- Go to All Programs >> Microsoft SQL Server 2008 >> Configuration Tools >> SQL Server Configuration Manager >> Select TCP/IP
- Right Click on TCP/IP >> Click on Enable
You must restart SQL Server Services for all the changes to take effect. Right click and go to menu properties to select location where default port of SQL Server can be changed.
I got Solution for me :
Open "SQL Server Configuration Manager"
Now Click on "SQL Server Network Configuration" and Click on "Protocols for Name"
Right Click on "TCP/IP" (make sure it is Enabled) Click on Properties
Now Select "IP Addresses" Tab -and- Go to the last entry "IP All"
Enter "TCP Port" 1433.
Now Restart "SQL Server .Name." using "services.msc" (winKey + r)
It Will Work...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With