Connecting ColdFusion to SQL Server 2005 Express

Here is a quick guide to connecting ColdFusion to a local instance of SQL Server 2005 Express.

My first attempt to do this seemingly simple task resulted in an “Error establishing socket. Connection refused: connect” error when trying to create a new data source. The cause of this error is that by default, SQL Server Express does not allow for connections over TCP/IP ports. To create the data source, we first need to configure SQL Server and enable connections over TPC/IP. The process is pretty easy, so lets get started!

First, you want to open the SQL Server Configuration Manger by choosing Start » All Programs » Microsoft SQL Server 2005 » Configuration Tools » SQL Server Configuration Manger. Next, in the left sidebar of the Configuration Manager, expand the SQL Server 2005 Network Configuration node. Now click on the Protocols for SQLEXPRESS node. Now in the right hand pane, double-click on the TCP/IP item. This will open the TCP/IP Properties window.

In the TCP/IP Properties window, choose Yes from the dropdown list in the Enabled row. Next we need to configure the IP addresses that are to receive connections on, so click on the IP Address tab. Look for the section named IPAll and enter in the port that SQL Server will listen for connections on. In the TCP Port row, type in 1433 (or any other port number you wish to use). Now click the OK button. You will be prompted to Restart the SQL Server (do this using either the Services control panel applet or by using SLQ Server Management Studio Express).

Now you should be able to connect your ColdFusion to SQL Server 2005 Express!

2 Responses to “Connecting ColdFusion to SQL Server 2005 Express”

  1. Frank said on June 22nd, 2007 at 11:43 am

    How do you connect sql server 2005 express to coldfusion mx 7. I have tried everything. What do I use for the username and passsword in Coldfusion Administrator.

  2. Jeff Schmidt said on August 29th, 2007 at 5:57 am

    Thanks for this. It was very helpful. I’m using Cold FusionMX Server and at this point I can now get the page to hit the database but the user I am specifying is not being recognized. I am not well versed in the Jedi art of the dba so if somebody can walk me through the proper user setup I will name my next child after you (or the appropriate gender specific alternative). Here’s the error:

    Data source MyDatabase verification failed.
    The root cause was that: java.sql.SQLException: [Macromedia][SQLServer JDBC Driver][SQLServer]Login failed for user ‘myuser’. The user is not associated with a trusted SQL Server connection.

Zen-To-Done