From: Darin Ginther Date: 2009-01-01T00:43:19+09:00 Subject: Re: Creating a class for returing DB results Thanks again, guys... Final solution below for reference: class Dbutil attr_accessor :mydb, :dbuser, :dbpw, :table, :lead_type_code require 'DBI' def initialize(mydb, dbuser, dbpw, table, lead_type_code) @mydb = mydb @dbuser = dbuser @dbpw = dbpw @table = table @lead_type_code = lead_type_code end def counttable dbh= DBI.connect(@mydb, @dbuser, @dbpw, @table, @lead_type_code) sth = dbh.execute("SELECT count(*) FROM #@table where code = #@lead_type_code") row = sth.fetch yield row[0] sth.finish dbh.disconnect end end -- Posted via http://www.ruby-forum.com/.