Skip to main content
Nov 10, 2013

Microsoft SQL Server Express can be used in working environment but connecting to the instance from other machine can provide the error message:

"An error has occurred while establishing a connection to the server."

This error message can have a couple of causes. At the first place check whether this particular instance allows remote connections. Default installation doesn't allow so you need to enable this option first.
 
Connection string could look like as follows:

Data Source=[pc name]\SQLEXPRESS; database=[database name]; uid=[user name]; pwd=[user password]

However, this could work sometime but in other cases you can experience the following error:

"SQL Server does not exist or access denied"

For this to resolve you need to specify port number of SQL Express in the connection string.

How to determine SQL Server port number

1) Go to
 
All Programs > Microsoft SQL Server 2005 > Configuration Tools > SQL Server Configuration Manager
 
2) SQL Server Network Configuration > Protocols for SQLEXPRESS
 
3) Double-click the "TCP/IP"
 
4) Under the "IP Addresses", find the "TCP Dynamic Ports".

5) Use the port number as part of the connection string (port 1433 is used by default in many instances):

Data Source=[pc name]\SQLEXPRESS, [port number] ; database=[database name =]; uid=[user name]; pwd=[user password]