Tiny_tds: Connect: Server name not found in the configuration files

Richard77 picture Richard77 · Oct 13, 2012 · Viewed 7.7k times · Source
require "rubygems"
require "tiny_tds"

client = TinyTds::Client.new(:username => 'sa', :password => '', :host => 'RICHARD_PC\SQLEXPRESS')
result = client.execute("SELECT * FROM [Contacts]")

result.each do |row|
   //Do something
 end

I keep getting the same error: "Connect: Server name not found in the configuration files". All I need to do is to be at least be able to connect with Sql Server. So if the host is not the sqlexpress instance installed on my machine, what is it then? In the Github website it said this host => 'mydb.host.net' (:host - Used if :dataserver blank. Can be an host name or IP.)

Thanks for helping.

Answer

Klaus picture Klaus · Oct 13, 2012

Either use :dataserver => 'RICHARD_PC\SQLEXPRESS' Or use :host => 'RICHARD_PC', :port => 1433