This is the code that I use to connect to SQL Server 2012 Express. My file 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 get the following error:
in 'execute': closed connection (TinyTds :: Error) from Connect.rb: in 'Main'
when I replace the above code as follows:
client = TinyTds::Client.new( :username => 'sa', :password => 'sapassword', :host => 'localhost', :port => 1433, :database => 'ContactsDB')
I get the following error:
in 'connect': cannot connect: Adaptive server is unavailable or does not exist
What causes this error and how to fix it?
ruby sql-server tiny-tds
Richard77
source share