Forum: Ruby ODBC, 'Sql server', XP: beyond connection

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ed H. (Guest)
on 2008-11-24 22:43
I believe I've connected to Microsofts' SQL Express, however, I'm stuck.

I'm happy this succeeds!
Using Windows XP, 1-Click Installer Ruby/Windows installation (1.86).
Using ODBC, and SQLEXPRESS 2005.

I can read all the columns in a row, but not individual columns with
'rows[]'.

#--CODE--

require 'dbi'
dbh= DBI.connect('DBI:ODBC:driver=SQL
Server;server=ehcomp;database=my_project;uid=sa;pwd=password')

rows= dbh.select_all('select projno,project,projshort from projects')

puts rows[0]  # outputs the three columns on row 0

dbh.disconnect

#---END CODE---

How do I output individual columns with rows?

A lot of things are additionally problematic, like 'fetch' returns an
error, 'execute' returns a 'garbage collection' error.  I've got this
far using 'select_all'.

Is there a windows/ruby/ODBC/SQL server online help somewhere?
Ed H. (Guest)
on 2008-12-01 06:53
Though I posted on this forum, I found a valuable answer
serendipitiously on a Google Forum.  Apparently this forum automatically
posts material on Google's forum.  Yet the answer is directed to me.

Thanks Aldric!  I was using rows[0,0], which didn't work.  Your
rows[0][0] works well.

From: Aldric G. <"aldric[removeme]"@trevoke.net>
Date: Sat, 29 Nov 2008 09:45:11 +0900
Local: Fri, Nov 28 2008 7:45 pm
Subject: Re: ODBC, 'Sql server', XP: beyond connection

How about rows[0][0] ?
These two websites have been really useful for me:
http://www.kitebird.com/articles/ruby-dbi.html
http://www.troubleshooters.com/codecorn/ruby/datab...

Good luck!

--Aldric
This topic is locked and can not be replied to.