Forum: RForum Getting Data from MS Access Database

Posted by Joe Martin (redlightg20)
on 2009-09-04 17:58
Hello

I'm switching some scripts over to Ruby from VBS.  One of my scripts
talks with a small Access database.  So far, I've been able to connect
to the database with win32ole, and bring back results of a query.  The
problem is, I can't seem to figure out how to pull up the results of a
query by providing a single field name.

For example, my VBS code would look something like this

recordset.Open("SELECT * FROM TABLENAME WHERE FIELDNAME1 =
'somestring'")
recordset.MoveFirst
do until recordset.EOF = true
   variable1 = recordset("FIELDNAME1")
   variable2 = recordset("FIELDNAME2")
   #and some other processing here, etc
end if

What I'm asking is, is it possible to process data from a recordset by
referencing the FIELDNAME in Ruby?  I'm using the example from
http://rubyonwindows.blogspot.com/2007/06/using-ru...
but I can only seem to pull field data by referencing the index number
(recordset[1]) of that field, and not the field name
recordset['FIELDNAME'].

Thanks!
Posted by Joe Martin (redlightg20)
on 2009-09-04 18:00
Sorry, meant to post this in the Ruby forum.  Mods please move it there.

Thanks.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.