Forum: Ruby ODBC Connection

Posted by Israel T. (israel_t)
on 2012-09-11 22:46
Hi,

I have an ODBC (sql server 2005) connection but recently I needed to
reconfigure the odbc to connect to another sql server, not the local
one.

Since then rubi cannot establish connection thru ODBC. If I reconfigure
the ODBC connection back to the local server it works fine.

Any idea what went wrong?

Thanks

Code:

def fetch(query)
    ODBC::connect('odbc', 'user', 'password') do |dbc|
      stmt = dbc.run(query)
      result_set = []
      stmt.each do |row|
        result_set << row
      end
      result_set
    end
  end
Posted by Damjan Rems (ther)
on 2012-09-12 21:14
Israel T. wrote in post #1075534:
> Hi,
>
> I have an ODBC (sql server 2005) connection but recently I needed to
> reconfigure the odbc to connect to another sql server, not the local
> one.
>
> Since then rubi cannot establish connection thru ODBC. If I reconfigure
> the ODBC connection back to the local server it works fine.
>
> Any idea what went wrong?
>
> Thanks
>
> Code:
>
> def fetch(query)
>     ODBC::connect('odbc', 'user', 'password') do |dbc|
>       stmt = dbc.run(query)
>       result_set = []
>       stmt.each do |row|
>         result_set << row
>       end
>       result_set
>     end
>   end

Do you have odbc resource defined in odbc connections.

I use tiny_tds https://github.com/rails-sqlserver/tiny_tds since it 
doesn't require any other local settings. And it works without problems 
on Linux and Windows.

by
TheR
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.