ODBC, MS SQL Server

Discussion in 'Ruby' started by Bolo, Jan 5, 2007.

  1. Bolo

    Bolo Guest

    Hello

    I try to connect ruby to a MS SQL database . This the error message.

    b.michelin@srv-mq-lamp2:~$ irb1.8
    irb(main):001:0> require "dbi"
    => true
    irb(main):002:0> dbh = DBI.connect('dbi:ODBC:DataBase', 'user',
    'password')
    WARNING: no ODBC driver manager found.
    DBI::DatabaseError: INTERN (0) [RubyODBC]Cannot allocate SQLHENV
    from /usr/lib/ruby/1.8/DBD/ODBC/ODBC.rb:95:in `connect'
    from /usr/lib/ruby/1.8/dbi.rb:424:in `connect'
    from /usr/lib/ruby/1.8/dbi.rb:215:in `connect'
    from (irb):2

    Can You help me

    Thanks
    Bolo, Jan 5, 2007
    #1
    1. Advertising

  2. Bolo

    gregarican Guest

    This might sound silly, but are you using a Windows-based PC? Judging
    by the command line prompt it doesn't appear to be the case. If so then
    you should load UNIX ODBC I believe...

    Bolo wrote:
    > Hello
    >
    > I try to connect ruby to a MS SQL database . This the error message.
    >
    > b.michelin@srv-mq-lamp2:~$ irb1.8
    > irb(main):001:0> require "dbi"
    > => true
    > irb(main):002:0> dbh = DBI.connect('dbi:ODBC:DataBase', 'user',
    > 'password')
    > WARNING: no ODBC driver manager found.
    > DBI::DatabaseError: INTERN (0) [RubyODBC]Cannot allocate SQLHENV
    > from /usr/lib/ruby/1.8/DBD/ODBC/ODBC.rb:95:in `connect'
    > from /usr/lib/ruby/1.8/dbi.rb:424:in `connect'
    > from /usr/lib/ruby/1.8/dbi.rb:215:in `connect'
    > from (irb):2
    >
    > Can You help me
    >
    > Thanks
    gregarican, Jan 5, 2007
    #2
    1. Advertising

  3. Bolo

    Bolo Guest

    Hello, Hello

    > This might sound silly, but are you using a Windows-based PC?


    No I use Debian etch. When i this command

    # isql YOUR_DB_DEFINITION_NAME USERNAME PASSWORD
    +---------------------------------------+
    | Connected! |
    | |
    | sql-statement |
    | help [tablename] |
    | quit |
    | |
    +---------------------------------------+
    SQL> select * from users; (again, do this for a table that exists in
    your db)
    +------------+-------------------------------+
    | id | login |
    +------------+-------------------------------+
    | 1 | user1 |
    | 3 | user2 |
    +------------+-------------------------------+
    2 rows affected
    2 rows returned
    SQL> quit

    it's working
    Bolo, Jan 5, 2007
    #3
  4. Bolo

    gregarican Guest

    Hmmm. And you have UNIX ODBC loaded then I would assume too. Here's a
    thread I googled across in terms of Debian UNIX ODBC access -->
    http://mail.easysoft.com/pipermail/unixodbc-support/2004-November/000237.html.
    Perhaps it might apply to you?

    Bolo wrote:
    > Hello, Hello
    >
    > > This might sound silly, but are you using a Windows-based PC?

    >
    > No I use Debian etch. When i this command
    >
    > # isql YOUR_DB_DEFINITION_NAME USERNAME PASSWORD
    > +---------------------------------------+
    > | Connected! |
    > | |
    > | sql-statement |
    > | help [tablename] |
    > | quit |
    > | |
    > +---------------------------------------+
    > SQL> select * from users; (again, do this for a table that exists in
    > your db)
    > +------------+-------------------------------+
    > | id | login |
    > +------------+-------------------------------+
    > | 1 | user1 |
    > | 3 | user2 |
    > +------------+-------------------------------+
    > 2 rows affected
    > 2 rows returned
    > SQL> quit
    >
    > it's working
    gregarican, Jan 5, 2007
    #4
  5. Bolo

    Bolo Guest

    I don't the anwsers to his question

    my db definition
    $ nano /etc/odbc.ini

    [Corporate]
    Driver = FreeTDS
    Description = ODBC connection via FreeTDS
    Trace = No
    Servername = Corporate
    Database = FrontOffice


    nano /etc/odbcinst.ini:


    [FreeTDS]
    Description = TDS driver (Sybase/MS SQL)
    Driver = /usr/lib/odbc/libtdsodbc.so
    Setup = /usr/lib/odbc/libtdsS.so
    CPTimeout =
    CPReuse =
    FileUsage = 1

    > Hmmm. And you have UNIX ODBC loaded then I would assume too. Here's a
    > thread I googled across in terms of Debian UNIX ODBC access -->
    > http://mail.easysoft.com/pipermail/unixodbc-support/2004-November/000237.html.
    > Perhaps it might apply to you?
    >
    > Bolo wrote:
    > > Hello, Hello
    > >
    > > > This might sound silly, but are you using a Windows-based PC?

    > >
    > > No I use Debian etch. When i this command
    > >
    > > # isql YOUR_DB_DEFINITION_NAME USERNAME PASSWORD
    > > +---------------------------------------+
    > > | Connected! |
    > > | |
    > > | sql-statement |
    > > | help [tablename] |
    > > | quit |
    > > | |
    > > +---------------------------------------+
    > > SQL> select * from users; (again, do this for a table that exists in
    > > your db)
    > > +------------+-------------------------------+
    > > | id | login |
    > > +------------+-------------------------------+
    > > | 1 | user1 |
    > > | 3 | user2 |
    > > +------------+-------------------------------+
    > > 2 rows affected
    > > 2 rows returned
    > > SQL> quit
    > >
    > > it's working
    Bolo, Jan 5, 2007
    #5
  6. Bolo

    gregarican Guest

    I think a reply message in that thread pertained to file access perms
    on those odbc files. Check the two ini files and ensure that the perms
    are botching things up.

    Bolo wrote:
    > I don't the anwsers to his question
    >
    > my db definition
    > $ nano /etc/odbc.ini
    >
    > [Corporate]
    > Driver = FreeTDS
    > Description = ODBC connection via FreeTDS
    > Trace = No
    > Servername = Corporate
    > Database = FrontOffice
    >
    >
    > nano /etc/odbcinst.ini:
    >
    >
    > [FreeTDS]
    > Description = TDS driver (Sybase/MS SQL)
    > Driver = /usr/lib/odbc/libtdsodbc.so
    > Setup = /usr/lib/odbc/libtdsS.so
    > CPTimeout =
    > CPReuse =
    > FileUsage = 1
    >
    > > Hmmm. And you have UNIX ODBC loaded then I would assume too. Here's a
    > > thread I googled across in terms of Debian UNIX ODBC access -->
    > > http://mail.easysoft.com/pipermail/unixodbc-support/2004-November/000237.html.
    > > Perhaps it might apply to you?
    > >
    > > Bolo wrote:
    > > > Hello, Hello
    > > >
    > > > > This might sound silly, but are you using a Windows-based PC?
    > > >
    > > > No I use Debian etch. When i this command
    > > >
    > > > # isql YOUR_DB_DEFINITION_NAME USERNAME PASSWORD
    > > > +---------------------------------------+
    > > > | Connected! |
    > > > | |
    > > > | sql-statement |
    > > > | help [tablename] |
    > > > | quit |
    > > > | |
    > > > +---------------------------------------+
    > > > SQL> select * from users; (again, do this for a table that exists in
    > > > your db)
    > > > +------------+-------------------------------+
    > > > | id | login |
    > > > +------------+-------------------------------+
    > > > | 1 | user1 |
    > > > | 3 | user2 |
    > > > +------------+-------------------------------+
    > > > 2 rows affected
    > > > 2 rows returned
    > > > SQL> quit
    > > >
    > > > it's working
    gregarican, Jan 5, 2007
    #6
  7. Bolo

    Bolo Guest

    Ok Know i have this error message
    irb(main):002:0> dbh = DBI.connect('dbi:ODBC:Corporate',
    '*******','**********')
    DBI::DatabaseError: S1000 (0) [unixODBC][FreeTDS][SQL Server]Unable to
    connect to data source
    from /usr/lib/ruby/1.8/DBD/ODBC/ODBC.rb:95:in `connect'
    from /usr/lib/ruby/1.8/dbi.rb:424:in `connect'
    from /usr/lib/ruby/1.8/dbi.rb:215:in `connect'
    from (irb):2
    gregarican a écrit :

    > I think a reply message in that thread pertained to file access perms
    > on those odbc files. Check the two ini files and ensure that the perms
    > are botching things up.
    >
    > Bolo wrote:
    > > I don't the anwsers to his question
    > >
    > > my db definition
    > > $ nano /etc/odbc.ini
    > >
    > > [Corporate]
    > > Driver = FreeTDS
    > > Description = ODBC connection via FreeTDS
    > > Trace = No
    > > Servername = Corporate
    > > Database = FrontOffice
    > >
    > >
    > > nano /etc/odbcinst.ini:
    > >
    > >
    > > [FreeTDS]
    > > Description = TDS driver (Sybase/MS SQL)
    > > Driver = /usr/lib/odbc/libtdsodbc.so
    > > Setup = /usr/lib/odbc/libtdsS.so
    > > CPTimeout =
    > > CPReuse =
    > > FileUsage = 1
    > >
    > > > Hmmm. And you have UNIX ODBC loaded then I would assume too. Here's a
    > > > thread I googled across in terms of Debian UNIX ODBC access -->
    > > > http://mail.easysoft.com/pipermail/unixodbc-support/2004-November/000237.html.
    > > > Perhaps it might apply to you?
    > > >
    > > > Bolo wrote:
    > > > > Hello, Hello
    > > > >
    > > > > > This might sound silly, but are you using a Windows-based PC?
    > > > >
    > > > > No I use Debian etch. When i this command
    > > > >
    > > > > # isql YOUR_DB_DEFINITION_NAME USERNAME PASSWORD
    > > > > +---------------------------------------+
    > > > > | Connected! |
    > > > > | |
    > > > > | sql-statement |
    > > > > | help [tablename] |
    > > > > | quit |
    > > > > | |
    > > > > +---------------------------------------+
    > > > > SQL> select * from users; (again, do this for a table that exists in
    > > > > your db)
    > > > > +------------+-------------------------------+
    > > > > | id | login |
    > > > > +------------+-------------------------------+
    > > > > | 1 | user1 |
    > > > > | 3 | user2 |
    > > > > +------------+-------------------------------+
    > > > > 2 rows affected
    > > > > 2 rows returned
    > > > > SQL> quit
    > > > >
    > > > > it's working
    Bolo, Jan 5, 2007
    #7
  8. Bolo

    gregarican Guest

    I would suggest googling around the FreeTDS message boards. When I just
    did it seems as if your situation isn't unique. Here's something that
    was referred to in terms of ensuring that UNIX ODBC works in
    conjunction with FreeTDS -->
    http://www.freetds.org/userguide/odbcombo.htm#E.G.SAMPLEODBCCOMBO. HTH!

    Bolo wrote:
    > Ok Know i have this error message
    > irb(main):002:0> dbh = DBI.connect('dbi:ODBC:Corporate',
    > '*******','**********')
    > DBI::DatabaseError: S1000 (0) [unixODBC][FreeTDS][SQL Server]Unable to
    > connect to data source
    > from /usr/lib/ruby/1.8/DBD/ODBC/ODBC.rb:95:in `connect'
    > from /usr/lib/ruby/1.8/dbi.rb:424:in `connect'
    > from /usr/lib/ruby/1.8/dbi.rb:215:in `connect'
    > from (irb):2
    > gregarican a écrit :
    >
    > > I think a reply message in that thread pertained to file access perms
    > > on those odbc files. Check the two ini files and ensure that the perms
    > > are botching things up.
    > >
    > > Bolo wrote:
    > > > I don't the anwsers to his question
    > > >
    > > > my db definition
    > > > $ nano /etc/odbc.ini
    > > >
    > > > [Corporate]
    > > > Driver = FreeTDS
    > > > Description = ODBC connection via FreeTDS
    > > > Trace = No
    > > > Servername = Corporate
    > > > Database = FrontOffice
    > > >
    > > >
    > > > nano /etc/odbcinst.ini:
    > > >
    > > >
    > > > [FreeTDS]
    > > > Description = TDS driver (Sybase/MS SQL)
    > > > Driver = /usr/lib/odbc/libtdsodbc.so
    > > > Setup = /usr/lib/odbc/libtdsS.so
    > > > CPTimeout =
    > > > CPReuse =
    > > > FileUsage = 1
    > > >
    > > > > Hmmm. And you have UNIX ODBC loaded then I would assume too. Here'sa
    > > > > thread I googled across in terms of Debian UNIX ODBC access -->
    > > > > http://mail.easysoft.com/pipermail/unixodbc-support/2004-November/000237.html.
    > > > > Perhaps it might apply to you?
    > > > >
    > > > > Bolo wrote:
    > > > > > Hello, Hello
    > > > > >
    > > > > > > This might sound silly, but are you using a Windows-based PC?
    > > > > >
    > > > > > No I use Debian etch. When i this command
    > > > > >
    > > > > > # isql YOUR_DB_DEFINITION_NAME USERNAME PASSWORD
    > > > > > +---------------------------------------+
    > > > > > | Connected! |
    > > > > > | |
    > > > > > | sql-statement |
    > > > > > | help [tablename] |
    > > > > > | quit |
    > > > > > | |
    > > > > > +---------------------------------------+
    > > > > > SQL> select * from users; (again, do this for a table that exists in
    > > > > > your db)
    > > > > > +------------+-------------------------------+
    > > > > > | id | login |
    > > > > > +------------+-------------------------------+
    > > > > > | 1 | user1 |
    > > > > > | 3 | user2 |
    > > > > > +------------+-------------------------------+
    > > > > > 2 rows affected
    > > > > > 2 rows returned
    > > > > > SQL> quit
    > > > > >
    > > > > > it's working
    gregarican, Jan 5, 2007
    #8
  9. Bolo

    Bolo Guest

    Thanks For your help Now it's working
    gregarican a écrit :

    > I would suggest googling around the FreeTDS message boards. When I just
    > did it seems as if your situation isn't unique. Here's something that
    > was referred to in terms of ensuring that UNIX ODBC works in
    > conjunction with FreeTDS -->
    > http://www.freetds.org/userguide/odbcombo.htm#E.G.SAMPLEODBCCOMBO. HTH!
    >
    > Bolo wrote:
    > > Ok Know i have this error message
    > > irb(main):002:0> dbh = DBI.connect('dbi:ODBC:Corporate',
    > > '*******','**********')
    > > DBI::DatabaseError: S1000 (0) [unixODBC][FreeTDS][SQL Server]Unable to
    > > connect to data source
    > > from /usr/lib/ruby/1.8/DBD/ODBC/ODBC.rb:95:in `connect'
    > > from /usr/lib/ruby/1.8/dbi.rb:424:in `connect'
    > > from /usr/lib/ruby/1.8/dbi.rb:215:in `connect'
    > > from (irb):2
    > > gregarican a écrit :
    > >
    > > > I think a reply message in that thread pertained to file access perms
    > > > on those odbc files. Check the two ini files and ensure that the perms
    > > > are botching things up.
    > > >
    > > > Bolo wrote:
    > > > > I don't the anwsers to his question
    > > > >
    > > > > my db definition
    > > > > $ nano /etc/odbc.ini
    > > > >
    > > > > [Corporate]
    > > > > Driver = FreeTDS
    > > > > Description = ODBC connection via FreeTDS
    > > > > Trace = No
    > > > > Servername = Corporate
    > > > > Database = FrontOffice
    > > > >
    > > > >
    > > > > nano /etc/odbcinst.ini:
    > > > >
    > > > >
    > > > > [FreeTDS]
    > > > > Description = TDS driver (Sybase/MS SQL)
    > > > > Driver = /usr/lib/odbc/libtdsodbc.so
    > > > > Setup = /usr/lib/odbc/libtdsS.so
    > > > > CPTimeout =
    > > > > CPReuse =
    > > > > FileUsage = 1
    > > > >
    > > > > > Hmmm. And you have UNIX ODBC loaded then I would assume too. Here's a
    > > > > > thread I googled across in terms of Debian UNIX ODBC access -->
    > > > > > http://mail.easysoft.com/pipermail/unixodbc-support/2004-November/000237.html.
    > > > > > Perhaps it might apply to you?
    > > > > >
    > > > > > Bolo wrote:
    > > > > > > Hello, Hello
    > > > > > >
    > > > > > > > This might sound silly, but are you using a Windows-based PC?
    > > > > > >
    > > > > > > No I use Debian etch. When i this command
    > > > > > >
    > > > > > > # isql YOUR_DB_DEFINITION_NAME USERNAME PASSWORD
    > > > > > > +---------------------------------------+
    > > > > > > | Connected! |
    > > > > > > | |
    > > > > > > | sql-statement |
    > > > > > > | help [tablename] |
    > > > > > > | quit |
    > > > > > > | |
    > > > > > > +---------------------------------------+
    > > > > > > SQL> select * from users; (again, do this for a table that exists in
    > > > > > > your db)
    > > > > > > +------------+-------------------------------+
    > > > > > > | id | login |
    > > > > > > +------------+-------------------------------+
    > > > > > > | 1 | user1 |
    > > > > > > | 3 | user2 |
    > > > > > > +------------+-------------------------------+
    > > > > > > 2 rows affected
    > > > > > > 2 rows returned
    > > > > > > SQL> quit
    > > > > > >
    > > > > > > it's working
    Bolo, Jan 5, 2007
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Graham
    Replies:
    13
    Views:
    1,023
    Peter Herndon
    Apr 18, 2005
  2. Frank Millman

    Problem with odbc and Sql Server

    Frank Millman, May 21, 2006, in forum: Python
    Replies:
    3
    Views:
    3,056
    Frank Millman
    May 22, 2006
  3. mierdatutis mi

    connect to ms sql server with odbc

    mierdatutis mi, Aug 31, 2009, in forum: Python
    Replies:
    1
    Views:
    604
    Sean DiZazzo
    Aug 31, 2009
  4. Replies:
    1
    Views:
    869
    Steven Cheng[MSFT]
    Nov 16, 2006
  5. Wes Gamble
    Replies:
    1
    Views:
    153
    Gerardo Santana Gómez Garrido
    Apr 5, 2006
Loading...

Share This Page