Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ruby

tiny-tds

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.

like image 492
Richard77 Avatar asked Sep 16 '25 22:09

Richard77


2 Answers

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

like image 146
Klaus Avatar answered Sep 18 '25 11:09

Klaus


For those running rails on vagrant, I got this error when my vagrant network connections stopped working (mostly just the DNS), so a reboot fixed the issue.

like image 25
Nathan Hanna Avatar answered Sep 18 '25 13:09

Nathan Hanna