rails-sqlserver / tiny_tds

TinyTDS - Simple and fast FreeTDS bindings for Ruby using DB-Library.
Other
607 stars 189 forks source link

Adaptive Server connection failed (TinyTds::Error) -- sort of #175

Closed ghost closed 9 years ago

ghost commented 9 years ago

This is difficult to explain, I'll do my best. I'm attempting to connect to a SqlServer 2014 server. From one environment I am successful; I'm failing from an other. The failing environment is throwing "Adaptive Server connection failed (TinyTds::Error)".

The good environment is like this Within network Running on remote server, Win 2008 R2 - Service Pack 1 Using ruby-1.9.3-p194 activerecord (4.1.4) activerecord-sqlserver-adapter (4.1.0) tiny_tds (0.6.1-x86-mingw32)

The failing environment is like this Laptop running Win7 Enterprise Service Pack 1 Connected to network via VPN Using ruby-1.9.3-p551 activerecord (4.1.8) activerecord-sqlserver-adapter (4.1.0) tiny_tds (0.6.2 x86-mingw32) Note: I can access database via SSMS 11.0.2100.60, and run the SQL script below. However, when I right click the server to get its properties, it throws an exception saying "VIEW SERVER STATE permission was denied on object 'server', database 'master'. (Microsoft SQL Server, Error 300)

The script that I am running is identical on both and is run from Rubymine 7.0

require 'active_record'
require 'activerecord-sqlserver-adapter'

ENV['prj_home'] = ENV['USERPROFILE']+'/RubymineProjects/Flowers'

class WorkTable < ActiveRecord::Base
end

begin
  yaml = File.join(ENV['prj_home'],'db','database.yml')
  ActiveRecord::Base.configurations = YAML.load_file(yaml)
rescue Exception => e
  puts "Couldn't load #{yaml} configuration file"
  p e.message, e.backtrace
  exit
end

sql = %Q{
  SELECT table_name FROM information_schema.tables
    where table_type = 'BASE TABLE'
    and TABLE_SCHEMA = 'dbo'
  order by TABLE_SCHEMA,TABLE_NAME
}
WorkTable.establish_connection(:bmk_dev)
tables = WorkTable.connection.raw_connection.execute(sql.gsub("\n", ' ').squeeze(' '))
ary = [['TABLE']]
tables.each(as: :array) {|row| ary << row.map{|e| e.nil? ? '' : e} }
puts ary

Can you provide any insight as to what might be happening? I'm at a loss. I can certainly continue to work using the remote server which is inside the network, but I would prefer to work from my local laptop. An understanding of what is happening is appreciated.

Thanks, dvn

metaskills commented 9 years ago

I believe your issue is related to #179

metaskills commented 9 years ago

Can you try the latest 4.2 adapter?

metaskills commented 9 years ago

Closing old issue.