ODBC, 'Sql server', XP: beyond connection

E

Ed Hardy

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?
 
A

Aldric Giacomoni

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?

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/database/index.htm

Good luck!

--Aldric
 
E

Ed Hardy

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 Giacomoni <"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/database/index.htm

Good luck!

--Aldric
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top