This is the code I'm using to connect to SQL server 2012 express. My file's name is Connect.rb.

require "rubygems"
require "tiny_tds"
client = TinyTds::Client.new(
                    :username => 'sa',
                    :password => 'sapassword',
                    :dataserver => 'localhost\SQLEXPRESS',
                    :database => 'ContactsDB')
result = client.execute("SELECT * FROM [Contacts]") 

When I run the code, I'm getting the following error:

in 'execute' :closed connection (TinyTds::Error) from Connect.rb: in 'main'

when I replace the above code by the following,

client = TinyTds::Client.new(
                    :username => 'sa',
                    :password => 'sapassword',
                    :host => 'localhost',
                    :port => 1433,
                    :database => 'ContactsDB')

I get the following error:

in 'connect': Unable to connect: Adaptive server is unavailable or does not exist

What's causing this error and how to fix it?

Edit
Report