Chris,
This was perfect to get me where I need to go. Thanks.
-Dwayne
···
-----Original Message-----
From: Chris Morris [mailto:chrismo@clabs.org]
Sent: Wednesday, January 29, 2003 8:40 AM
To: ruby-talk ML
Subject: Re: Connecting to a database…Here’s an ADO example
require ‘win32ole’
db = WIN32OLE.new(“ADODB.Connection”)
db.open "“Provider=SQLOLEDB;Data Source=MyServer;Database=MyDb;User
ID=sa;Password=password;”
rs = db.execute (“select * from MyTable”)
rs.MoveFirst
rows =
while !rs.eof
rowhash = {}
rs.fields.each do |field|
rowhash[field.name] = field.value
end
rows << rowhash
rs.MoveNext
endthis produces an array of hashes - each hash representing
each record
Chris
http://clabs.org