Ruby connnection string for sql server 2005

Discussion in 'Ruby' started by Shirish Nagar, Nov 10, 2010.

  1. Hi All,

    I am trying to fetch data from the database. Attached is my code, which
    I wrote to retrieve data. I am also pasting it here (in case, you are
    not able to see attachment):



    require 'dbi'

    conn = DBI.connect('DBI:ODBC:MY_DSN', 'username', 'password')

    sth = conn.execute("select * from table_name")
    rows = sth.fetch_all()
    col_names = sth.column_names
    puts rows
    puts col_names




    Using this code, I am able to display Column Names on output screen but
    not able to display Rows(data). It prints "null" value for the command
    "puts rows".

    Any kind of suggestion or help is highly appreciable.

    Thanks in Advance.

    Attachments:
    http://www.ruby-forum.com/attachment/5334/Ruby-ODBC.txt


    --
    Posted via http://www.ruby-forum.com/.
     
    Shirish Nagar, Nov 10, 2010
    #1
    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. Juan T. Llibre
    Replies:
    0
    Views:
    471
    Juan T. Llibre
    Jun 7, 2005
  2. Marco Lorenzini
    Replies:
    0
    Views:
    390
    Marco Lorenzini
    May 13, 2004
  3. farseer

    SQL Server 2005 + SQL Server Express

    farseer, Aug 7, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    350
    farseer
    Aug 8, 2006
  4. Wesley Chen
    Replies:
    0
    Views:
    228
    Wesley Chen
    Apr 7, 2009
  5. Wesley Chen
    Replies:
    9
    Views:
    245
    Sean O'Halpin
    Apr 14, 2009
Loading...

Share This Page