# ODBC, 'Sql server', XP: beyond connection

**URL:** <https://www.ruby-forum.com/t/odbc-sql-server-xp-beyond-connection/154052>\
**Category:** Ruby\
**Created:** [November 24, 2008, 9:43pm UTC](https://www.ruby-forum.com/t/odbc-sql-server-xp-beyond-connection/154052 "2008-11-24T21:43:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![devros](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7c8e57/32.png) [@devros](https://www.ruby-forum.com/u/devros)\
**Post date:** [November 24, 2008, 9:43pm UTC](https://www.ruby-forum.com/t/odbc-sql-server-xp-beyond-connection/154052/1 "2008-11-24T21:43:50Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![devros](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7c8e57/32.png) [@devros](https://www.ruby-forum.com/u/devros)\
**Post date:** [December 1, 2008, 5:53am UTC](https://www.ruby-forum.com/t/odbc-sql-server-xp-beyond-connection/154052/2 "2008-12-01T05:53:36Z")

</div>

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.kitebird.com/articles/ruby-dbi.html)

> **[Ruby DBI: Database Access](http://www.troubleshooters.com/codecorn/ruby/database/index.htm)**
>
> A website devoted to the Ruby programming language

Good luck!

–Aldric
