From: Dave Lilley Date: 2009-06-11T21:38:42+09:00 Subject: SQLite3 passing row data from 1 class to another I have code in one class that runs an SQL statement against a SQLite3 table and would like to return the resulting row back to another class as an array. here is my 'database' class.... require "sqlite3" class Dbase def initialize @db = SQLite3::Database.new( "customer" ) @db.results_as_hash = true end def rec_to_find (table, colname, tofind) stmt = "select * from #{table} where #{colname} = " + tofind row = @db.execute(stmt) result row end end I am having trouble in getting the resulting row (IT WILL always be either 1 row or no row being returned). this is the main program for what it is require "sqlite3_calls" db = Dbase.new puts 'customer name to find' cust_nos = gets.chomp row = db.rec_to_find("customers", "custnos", cust_nos) puts row and these are the errors i currently get, /customer_test$ ruby cust2.rbcustomer name to find 1 /usr/lib/ruby/1.8/sqlite3/errors.rb:62:in `check': no such column: custnos(SQLite3::SQLException) from /usr/lib/ruby/1.8/sqlite3/statement.rb:39:in `initialize' from /usr/lib/ruby/1.8/sqlite3/database.rb:154:in `new' from /usr/lib/ruby/1.8/sqlite3/database.rb:154:in `prepare' from /usr/lib/ruby/1.8/sqlite3/database.rb:181:in `execute' from ./sqlite3_calls.rb:12:in `rec_to_find' from cust2.rb:8 as mentioned above I will want the data back in as an array for further processing on individual fields, currently i cannot achieve this and be grateful for some help. Dave. -- Posted via http://www.ruby-forum.com/.