From: "Dwayne Smurdon @ DNA Media Pro" Date: 2003-01-30T15:02:04+09:00 Subject: Re: Connecting to a database.. This is a multi-part message in MIME format. ------=_NextPart_000_0116_01C2C7FA.C84FCE60 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit 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 > end > > # this produces an array of hashes - each hash representing > each record > > Chris > http://clabs.org > > > ------=_NextPart_000_0116_01C2C7FA.C84FCE60 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: Connecting to a database..

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 =3D = WIN32OLE.new("ADODB.Connection")
> db.open ""Provider=3DSQLOLEDB;Data = Source=3DMyServer;Database=3DMyDb;User
> ID=3Dsa;Password=3Dpassword;"
> rs =3D db.execute ("select * from = MyTable")
> rs.MoveFirst
> rows =3D []
> while !rs.eof
>   rowhash =3D {}
>   rs.fields.each do |field|
>     rowhash[field.name] =3D = field.value
>   end
>   rows << rowhash
>   rs.MoveNext
> end
>
> # this produces an array of hashes - each hash = representing
> each record
>
> Chris
> http://clabs.org
>
>
>

------=_NextPart_000_0116_01C2C7FA.C84FCE60--