If you have SQL Server 2005 Express installed and you attempt to add a DataSource connection to a Visual Studio project, you may encounter the following error:
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server)
To fix this, follow these steps:
Start by launching the SQL Server Configuration Manager.
It can usually be found under the Microsoft SQL Server 2005/Configuration Tools/SQL Server Configuration Manager path. You will be presented with the SQL Server Configuration Manager control panel.
- Expand the “SQL Server 2005 Network Configuration” option.
- Select the “Protocols for <YOUR_SERVER_NAME_HERE>”.
- In the right hand pane, there should be several options, one of which is “Named Pipes” and by default it should have a “Disabled” status.
- Right click the “Named Pipes” option.
- On the dropdown menu, select “Enable”.
You will receive a popup warning stating that the SQL service would have to be restarted in order for changes to take effect.
- Click “OK”.
The “Named Pipes” option will now show “Enabled”, but we still have to restart the service to take effect.
Now select the “SQL Server 2005 Services” option in the left hand panel.
- In the right hand panel, the “SQL Server (<YOUR_SERVER_NAME_HERE>)” option should be visible.
- It’s state should be “Running”.
- Select the blue arrow on the button bar, indicated above.
- When you hover over this button, the context help should state “Restart service”.
- Click this button to restart your SQL service and commit your changes.
The service will be stopped and restarted.
Trackback from your site.